mhaddon
09-12-2003, 03:30 PM
I am building a JSP application that cycles through various pages. I want to validate information from the user before the JSP processes. On the first JSP, I ask the user to select year ranges they are interested in. The basic validation I am trying to perform is ensuring the second year selected comes after or is the same as the first year selected (e.g. I don't want a range from 1994 to 1990, my query will fail).
Anyway the following is the script I have written to accomplish this:
<SCRIPT LANGUAGE=JavaScript>
function butCheckForm_onclick()
{
var myForm=document.form1;
if (myForm.year1.value > myForm.year2.value) {
alert("Second year selected must be greater or equal to first year selected");
myForm.year2.focus();
}
}
</SCRIPT>
Then I attach this function to the onclick method of my submit button. All works well, but when a user selects a first year that is larger than the second year, the alert box appears, but it has a Yes/No/Cancel format. I just want it to have an OK button and take the user back to the form to re-enter an appropriate year. What am I doing wrong?? Help!
Anyway the following is the script I have written to accomplish this:
<SCRIPT LANGUAGE=JavaScript>
function butCheckForm_onclick()
{
var myForm=document.form1;
if (myForm.year1.value > myForm.year2.value) {
alert("Second year selected must be greater or equal to first year selected");
myForm.year2.focus();
}
}
</SCRIPT>
Then I attach this function to the onclick method of my submit button. All works well, but when a user selects a first year that is larger than the second year, the alert box appears, but it has a Yes/No/Cancel format. I just want it to have an OK button and take the user back to the form to re-enter an appropriate year. What am I doing wrong?? Help!