Question
Form validation question - Javascript
Hey Gang,
I'm not too familiar with the syntax of Javascript, so I could use some help
with this (what I suspect is pretty easy).
I have a form field that will have a year value entered. The generic
checking that the field isn't left blank is there.. but I would like to also
check that the value entered is between 19yy and 20yy (not sure of the
actual ranges yet.
Here's my snippet for the filed being blank routine:
The name of the form is "ThisForm_Right", and the field name is "DOB_Year"
(to explain that piece in the code below)
if (ThisForm_Right.DOB_Year.value=="")
{
alert ("Please enter the YEAR of your DOB.");
ThisForm_Right.DOB_Year.focus();
return false;
}
Can some kind sole help with a modified version to also check for an entered
number range?
I suspect some sort of "And" statement, Like
If
(
ThisForm_Right.DOB_Year.Value==""
AND
Year.Value NOT between (1900 and 2006)
)
{
alert ("Please enter the YEAR of your DOB between 1900 and 2006.");
ThisForm_Right.DOB_Year.focus();
return false;
}
I just don't know the real syntax :>
Thanks
-D
I'm not too familiar with the syntax of Javascript, so I could use some help
with this (what I suspect is pretty easy).
I have a form field that will have a year value entered. The generic
checking that the field isn't left blank is there.. but I would like to also
check that the value entered is between 19yy and 20yy (not sure of the
actual ranges yet.
Here's my snippet for the filed being blank routine:
The name of the form is "ThisForm_Right", and the field name is "DOB_Year"
(to explain that piece in the code below)
if (ThisForm_Right.DOB_Year.value=="")
{
alert ("Please enter the YEAR of your DOB.");
ThisForm_Right.DOB_Year.focus();
return false;
}
Can some kind sole help with a modified version to also check for an entered
number range?
I suspect some sort of "And" statement, Like
If
(
ThisForm_Right.DOB_Year.Value==""
AND
Year.Value NOT between (1900 and 2006)
)
{
alert ("Please enter the YEAR of your DOB between 1900 and 2006.");
ThisForm_Right.DOB_Year.focus();
return false;
}
I just don't know the real syntax :>
Thanks
-D
