validating fields in a text box - how?
Posted: Mon May 18, 2009 5:09 am
hi all ,
in my website there is a page for entering details..
there is a 3 text boxes for entering date of birth
i have given a code for checking the values entered in the text
if the text box is left empty it will display an alert message..
but what i need is
date should be a value between 1 and 31. if the value entered is greater than 31, it should display an alert message
likewise month should be between 1 and 12 and year less than 2009..
what change should i make in the code??
please help me to solve this...
in my website there is a page for entering details..
there is a 3 text boxes for entering date of birth
Code: Select all
<td >Date of Birth</td>
<td ><input type="text" id="date" name="date" value="" class="box-200" /></td>
<td ><input type="text" id="month" name="month" value="" class="box-200" /></td>
<td ><input type="text" id="year" name="year" value="" class="box-200" /></td>
Code: Select all
function validate() {
if(document.form.date.value=="")
{
alert ('Please enter date');
return false;
}
if(document.form.month.value=="")
{
alert ('Please enter month.');
return false;
}
if(document.form.year.value=="")
{
alert ('Please enter year.');
return false;
}
}
but what i need is
date should be a value between 1 and 31. if the value entered is greater than 31, it should display an alert message
likewise month should be between 1 and 12 and year less than 2009..
what change should i make in the code??
please help me to solve this...