www.webdeveloper.com
Results 1 to 2 of 2

Thread: Future Date Validation

Hybrid View

  1. #1
    Join Date
    May 2012
    Posts
    4

    Exclamation Future Date Validation

    Hi All,

    I'm trying to get my Validation to check my calendar to ensure that the date being selected from the calendar is a future date.

    The code I am currently using is:

    Code:
    var dateString = document.form1.date.value;  
    var myDate = new Date(dateString);  
    var today = new Date();  
    if(document.forms.form1.date.value=="") 
    { 
    alert("Please select a date from the calendar."); 
    document.forms.form1.date.focus(); 
    return false; 
    }  
    else if (myDate<today)  
    {   
    alert("Please select a future date from the calendar."); 
    document.forms.form1.date.focus();
    return false; 
    }
    Unfortunatly it only validates the date, and not if the date captured is a future date. Ideally I would like it to check that the date selected is at least 29 days from the current date.

    Thanks

  2. #2
    Join Date
    Oct 2010
    Location
    Versailles, France
    Posts
    1,252
    See this page to get the rigth format of dateString. Since the methods setMonth(today.getMonth()+1) or setDate(today.getDate()+29) should allow to solve the problem with one Month or 29 days...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles