// Text box name for date = "indate"
Function check1 (Form)
{
For (I = 0; I <Form. length; I ++)
{
If (Form. elements [I]. value = "")
{
Alert ("complete! ")
Form. elements [I]. focus ();
Return;
}
If (Form. elements [I]. name = "indate ")
{
Var date = Form. elements [I]. value;
Len = date. length;
Var datearray = date. split ("-")
// Alert (datearray [1]);
Var year = parseInt (datearray [0]);
Var month = parseInt (datearray [1]);
Var day = parseInt (datearray [2]);
If (len = "")
{
Alert ("time cannot be blank ");
Return;
}
Else if (len> 10)
{
Alert ("incorrect date format ");
Return;
}
Else if (isNaN (year ))
{
Alert ("incorrect date format ");
Return;
}
Else if (year> 9999) | (year <100 ))
{
Alert ("incorrect date format ");
Return;
}
Else if (isNaN (month ))
{
Alert ("incorrect date format ");
Return;
}
Else if (month> 12) | (month <1 ))
{
Alert ("incorrect date format ");
Return;
}
Else if (isNaN (day ))
{
Alert ("incorrect date format ");
Return;
}
Else
{
Switch (month)
{
Case 1:
Case 3:
Case 5:
Case 7:
Case 8:
Case 10:
Case 12:
If (dat <0) | (day> 31 ))
{
Alert ("incorrect date format ");
Return;
}
Break;
Case 4:
Case 6:
Case 9:
Case 11:
If (day <0) | (day> 30 ))
{
Alert ("incorrect date format ");
Return;
}
Break;
Default:
If (year % 100 = 0) & (year % 4 = 0 ))
{
If (day <0) | (day> 29 ))
{
Alert ("incorrect date format ");
Return;
}
}
Else
{
If (day <0) | (day> 28 ))
{
Alert ("incorrect date format ");
Return;
}
}
}
}
}
}
Form. submit ();
}