12-05-2007, 04:39 AM
|
#1 (permalink)
|
|
The Visitor
Join Date: Dec 2007
Posts: 4
Thanks: 1
|
Problem with code in PHP file
Hello!
I hope you guys can help me out. I have a registration form on my website - that a coder created for me - that requires users to fill it out. If they forget to fill out a field, an alert or pop-up notifciation will display. For some reason, the current code I have for my state field does not display an alert to the user to choose a state. I want the user to choose a state if they live in the US. However, if they live outside of the US, the user should not be required to choose a state and an alert should not display. My codes are below (i was told this is javascript). If someone could tell me what's wrong with the code that would be greatly appreciated! If it is correct, and something is just wrong with my IE browser, let me know! Thanks!
if (document.regform.country.selectedIndex == 0) {
alert("Please select your country");
return false;
}
if (document.regform.state.selectedIndex == 0 && document.regform.country.options[document.regform.country.selectedIndex].value == "United States") {
alert("Please select your state");
return false;
}
|
|
|
|