Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: validate a date

  1. #1
    yen
    yen is offline
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    validate a date

    i got one text box..is let the user enter the borrow date using a javascript calendar. how to i block the user to enter the date earlier than today date?using the javascript?i mean...if the user enter date that earlier than today...got one alert message....plz help..
    thanx

  • #2
    Regular Coder
    Join Date
    Oct 2003
    Posts
    603
    Thanks
    2
    Thanked 1 Time in 1 Post
    what is the format of the date your users are inputting?

  • #3
    Senior Coder
    Join Date
    Jul 2005
    Location
    New York, NY
    Posts
    1,084
    Thanks
    4
    Thanked 19 Times in 19 Posts
    Use the date object:

    Code:
    var todayInMillisecond = (new Date()).getTime();
    var theirInput = prompt('Gimme a date, man!');
    if (todayInMillisecond > Date.parse(theirInput))
    {
      alert('Whoa there, time traveller, come on back to the future.');
    }


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •