User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 429,888 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,326 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 797 | Replies: 4
Reply
Join Date: Jan 2008
Location: India
Posts: 160
Reputation: sbv is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 7
sbv's Avatar
sbv sbv is offline Offline
Junior Poster

validatong combo value in asp.net using js

  #1  
Apr 16th, 2008
hi
i am developing a site in asp.net 1.0 for validation i have created a js function
where i am checking all controls for null

my text boxes are validated with that function but not combos.
here is the code i used to validate combos
                                        	
if(document.Form1.cboCity.selectedindex == 0)
{
	document.Form1.cboCity.focus();
	alert("Please Select Your Current	Location.");
	return false;   
}

This is not worked then i tryed this
if(document.Form1.cboCity.value == 0)
{
	document.Form1.cboCity.focus();
	alert("Please Select Your Current	Location.");
	return false;   
}

but nothing is done. also no error.

plz help.
Last edited by peter_budo : Apr 19th, 2008 at 8:41 am. Reason: Keep It Organized - please use [code] tags
Accept Challenges and Enjoy Coding... :)
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2006
Location: India
Posts: 6,870
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 23
Solved Threads: 345
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Lazy, Useless & Apathetic

Re: validatong combo value in asp.net using js

  #2  
Apr 16th, 2008
You seem to be in serious need of some good Javascript tutorials.

First of all, Javascript is case sensitive, hence selectedindex is not the same as selectedIndex. Also, the values of form controls are always of type string, so checking a textbox value for 0 seems pointless enough. It should be txtInput.value.length == 0.
Last edited by ~s.o.s~ : Apr 16th, 2008 at 1:43 pm.
I don't accept change. I don't deserve to live.

Happiness corrupts people.

Failing to value the lives of others cheapens your own.
Reply With Quote  
Join Date: Jan 2008
Location: India
Posts: 160
Reputation: sbv is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 7
sbv's Avatar
sbv sbv is offline Offline
Junior Poster

Re: validatong combo value in asp.net using js

  #3  
Apr 17th, 2008
hi
thanks for reply. but i didn't get solution yet..
Accept Challenges and Enjoy Coding... :)
Reply With Quote  
Join Date: Jun 2006
Location: India
Posts: 6,870
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 23
Solved Threads: 345
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Lazy, Useless & Apathetic

Re: validatong combo value in asp.net using js

  #4  
Apr 17th, 2008
You already have been given a solution; start reading some tutorials and post your latest attempt with the changes incorporated.
I don't accept change. I don't deserve to live.

Happiness corrupts people.

Failing to value the lives of others cheapens your own.
Reply With Quote  
Join Date: Jan 2008
Location: India
Posts: 160
Reputation: sbv is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 7
sbv's Avatar
sbv sbv is offline Offline
Junior Poster

Re: validatong combo value in asp.net using js

  #5  
Apr 18th, 2008
hi

actually i just copied and pasted the example from one of the tutorial. But its not working. then i tried for values of combo then its showing undefined. that means its not found the controls. why so !
Accept Challenges and Enjoy Coding... :)
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 8:47 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC