ive written a html form that allows a user to select their birthday from a drop down menu. Once the user submits the form those values are then stored into variables in a javascript function that will will first check that the user selected a value from each field(month, day year) and then verify the birthday is a valid date. If everything is correct then the next form is suppose to load. My problem is that once the function verifies that a month and day has been selected the program loads the next form without checking the year.
Here is the java script function:
function checkBday() {
var day = document.forms["register"]["DateOfBirth_Day"].value;
var month = document.forms["register"]["DateOfBirth_Month"].value;
var year = document.forms["register"]["DateOfBirth_Year"].value;
if(month == "- Month -") {
alert("Select a month");
return false;
}
if(day == "- Day -") {
alert("Select a day");
return false;
}
if(year == "- year -") {
alert("Select a year");
return false;
}
if((month == 2 && day > 28) || (month == 4 && day == 31) || (month == 6 && day == 31) || (month == 9 && day == 31) || (month == 11 && day == 31)) {
alert("Invalid birthday");
return false;
}
}
Here is the function call:
if(checkBday() == false) {
return false; }
else {
alert("Registration was successful!");
return true; }
- Day- - Month - and - Year- are default values if nothing is selected from the drop down menu. Thanks for the help im a noob at this.