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.

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 .

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

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

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 article has been dead for over six months. Start a new discussion instead.