Monday, 7 January 2013

Javascript Date Validation


<script type="text/javascript" language="javascript">




    var dateString1 = "09/18/2012";
    var dateString2 = "10/18/2012";
 
        var myDate = new Date(dateString1);
       
        var today = new Date(dateString2);
     
        if (dateString1 == "") {
         
            alert('REQUIRED FIELD ERROR: Please enter date in field!')
           
        }
        else if (myDate < today) {
         
            alert('You cannot enter a date in the past!')
         
        }
     
   
</script>

No comments:

Post a Comment