Java script Validation is not working.Please help.
Code in Html file:
=============
<select name="fldCountry" id="fldCountry" onchange="updateStates(this.form)">
</select>
fldCountry --> dropdown list Id
code in js file:
==========
if ( document.form.getElementById("fldCountry").value=="Country:" )
{
alert ( "Please fill in the 'Country' field." );
chk = false;
}
Populating the list:
==============
function resetForm(theForm)
{
/* reset makes */
theForm.fldCountry.options[0] = new Option("Country:", "");
for (var i=0; i<fldCountry.length; i++)
{
theForm.fldCountry.options[i+1] = new Option(fldCountry, fldCountry);
}
theForm.fldCountry.options[0].selected = true;
/* reset States */
theForm.fldStates.options[0] = new Option("State:", "");
theForm.fldStates.options[0].selected = true;
}
function updateStates(theForm) {
var fldCountry = theForm.fldCountry.options[theForm.fldCountry.options.selectedIndex].value;
var newStates = fldStates[fldCountry];
theForm.fldStates.options.length = 0;
theForm.fldStates.options[0] = new Option("State:", "");
for (var i=0; i<newStates.length; i++) {
theForm.fldStates.options[i+1] = new Option(newStates, newStates);
}
theForm.fldStates.options[0].selected = true;
}
Java Script validation Problem
Moderator: General Moderators
Re: Java Script validation Problem
Have you checked W3Schools?
http://www.w3schools.com/
If no answers, try using a php code to do the same function, and it should work.
http://www.w3schools.com/
If no answers, try using a php code to do the same function, and it should work.