0

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.

2
Contributors
4
Replies
5
Views
9 Years
Discussion Span
Last Post by sbv
0

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 .

0

hi
thanks for reply. but i didn't get solution yet.. :(

0

You already have been given a solution; start reading some tutorials and post your latest attempt with the changes incorporated.

0

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 !

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.