//Text box name for date = "indate"
function check1(Form)
{
for (i = 0; i {
if (Form.elements[i].value == "")
{
alert("Please fill in completely!")
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 empty ");
return;
}
else if (len > 10)
{
alert("Date format is incorrect");
return;
}
else if (isNaN(year))
{
alert("Date format is incorrect");
return;
}
else if ((year > 9999) || (year {
alert("Date format is incorrect");
return;
}
else if (isNaN(month))
{
alert( "The date format is incorrect");
return;
}
else if ((month > 12) || (month {
alert("The date format is incorrect ");
return;
}
else if (isNaN(day))
{
alert("Date format is incorrect");
return;
}
else
{
switch (month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
if ((dat 31))
{
alert("Date format is incorrect");
return;
}
break;
case 4:
case 6:
case 9:
case 11:
if ((day 30))
{
alert( "Date format is incorrect");
return;
}
break;
default:
if ((year % 100 == 0) && (year % 4 == 0))
{
if ((day 29))
{
alert("Date format is incorrect");
return;
}
}
else
{
if ((day 28))
{
alert("Date format is incorrect");
return;
}
}
}
}
}
}
Form.submit();
}