// 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 ();
}