Home > Articles > Simple JavaScript validation for dates

In this post i would like to explain about Simple JavaScript date validation.  We can  check dates with individual drop down boxes for day, month and year. In the validation part we have to check with first year , next  month and next day. In this we may not get the correct validations.

Simple JavaScript validation for dates | Anil Labs

Simple JavaScript validation for dates | Anil Labs

For this below function is very useful to do the validations for dates.

  function datechecking(){
   var before=new Date();
   before.setFullYear(2011,8,30); // members before spet 30
   var upto=new Date();
   upto.setFullYear(2011,9,15); // members before oct 15
   var today = new Date();

First create an object to Date(). And set the date which we don’t want to register before and set the date which don’t want to register after some date. And assign today date.
Below conditions to check before and after statements.

 if(today <= before){
   alert("before statement");
 }else if(today <= upto){
  alert("after statement");
You may also like
How to convert feeds to html using javascript and php
Multi-language support for web application with MySql and PHP
PHP Headers for your Web Application
PHP Captcha and reCaptcha options for web forms using javascript

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.