Question
Validate Date Range - Javascript
Hi Gang,
This is close to a repost... but more of a followup to a thread that has
already moved down everyones list.
I have a pretty simple form validation routine I need to implement, but I
don't know the Javascript syntax well enough to work it out (my background
is VBscript, but this needs to be client side). I received some good URL's
to check out some free scripts.. but unfortunately, I don't know javascript
well enough to hack them up correctly.
If someone can help out with a bit of code, it would be a huge help.
What I need to do is validate a numeric range as well as not leaving the
field blank.
For example what is entered must be a number between 1900 and 2006.
Here is what I am using for the basic required function:
The name of the form is "ThisForm_Right", and the field name is "DOB_Year"
(to explain the 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
This is close to a repost... but more of a followup to a thread that has
already moved down everyones list.
I have a pretty simple form validation routine I need to implement, but I
don't know the Javascript syntax well enough to work it out (my background
is VBscript, but this needs to be client side). I received some good URL's
to check out some free scripts.. but unfortunately, I don't know javascript
well enough to hack them up correctly.
If someone can help out with a bit of code, it would be a huge help.
What I need to do is validate a numeric range as well as not leaving the
field blank.
For example what is entered must be a number between 1900 and 2006.
Here is what I am using for the basic required function:
The name of the form is "ThisForm_Right", and the field name is "DOB_Year"
(to explain the 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
