INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Validation

Validate: StartDate < EndDate by Rougy
Posted: 10 Jun 03 (Edited 16 Jun 03)

Works like a charm for me:

Here's the function:

function checkOut()
{
  if (document.survey.txtSD.value == "Start Date") {
    alert("Please enter a start date.");
    return(false);
  }
  else {
    if (document.survey.txtSD.value != "End Date") {
      If (Date.parse(document.survey.txtSD.value) > Date.parse(document.survey.txtED.value)) {
        alert("Invalid Date Range!\nStart Date cannot be after End Date!")
        return false;
      }
      else {document.survey.action = "document.asp";}
    }
    else {document.survey.action = "document.asp";}
  }
}

Here's the form:

<form name="survey" onSubmit="return checkOut(this.form)" method="post">
   <input type="text" name="txtSD" id="StartDateID" value="Start Date" size="8" maxlength=10>
   <input type="text" name="txtED" id="EndDateID" value="End Date" size="8" maxlength=10>
   <input type="Submit" name="cmdSubmit" value="Submit">
</form>

Most of you should be able to cut and paste as you need.  The presentation is poor (forgive me, it's hard to get the "}" parts to line up right.)  This came in real handy for me.  Hope it helps.

Back to Javascript FAQ Index
Back to Javascript Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close