I am currently using a function to validate a form on the client side
(see code below). At the end of the function, I would like it to also
compare a startDate against an endDate to ensure that the endDate is
greater than (comes after) the startDate. The date format I'm using is
MM/DD/YYYY and it's writing to an MS SQL Server 2000 database table
via ASP. THANKS!!!
function ValidateForm()
{
//validate STATUS element
if (document.form. status[0].selected)
{
alert("Please select a Status");
document.form.s tatus.focus();
return false;
}
//validate NAME element
if (document.form. name.value=="")
{
alert("Please enter a Name")
document.form.n ame.select();
return false;
}
//validate START DATE element
if ((document.form .startDate.valu e=="") ||
(document.form. startDate.value =="mm/dd/yyyy"))
{
alert("Please enter a valid Start Date")
document.form.s tartDate.focus( );
return false;
}
//validate END DATE element
if ((document.form .endDate.value= ="") ||
(document.form. endDate.value== "mm/dd/yyyy"))
{
alert("Please enter a valid End Date")
document.form.e ndDate.focus();
return false;
}
//validate DATES
//check to ensure that endDate is > startDate
}
(see code below). At the end of the function, I would like it to also
compare a startDate against an endDate to ensure that the endDate is
greater than (comes after) the startDate. The date format I'm using is
MM/DD/YYYY and it's writing to an MS SQL Server 2000 database table
via ASP. THANKS!!!
function ValidateForm()
{
//validate STATUS element
if (document.form. status[0].selected)
{
alert("Please select a Status");
document.form.s tatus.focus();
return false;
}
//validate NAME element
if (document.form. name.value=="")
{
alert("Please enter a Name")
document.form.n ame.select();
return false;
}
//validate START DATE element
if ((document.form .startDate.valu e=="") ||
(document.form. startDate.value =="mm/dd/yyyy"))
{
alert("Please enter a valid Start Date")
document.form.s tartDate.focus( );
return false;
}
//validate END DATE element
if ((document.form .endDate.value= ="") ||
(document.form. endDate.value== "mm/dd/yyyy"))
{
alert("Please enter a valid End Date")
document.form.e ndDate.focus();
return false;
}
//validate DATES
//check to ensure that endDate is > startDate
}
Comment