validation - jQuery : validate date -


i using jquery validation plugin 'jquery.validation.js' validate date data type in 'date_of_birth' field

i want display custom message above "date_of_birth" filed 'age should minimum of 16' .

so have written following customised validation code :

{literal} jquery.validator.addmethod("dob", function (value, element) { var startdate = $('#date_of_birth').val(); var findate = 01/03/2012 var age=date.parse(findate)-date.parse(startdate); if (age >= 16){      return false;       }       else      {     return true;      }  }, "age should minimum of 16"); {/literal} 

custom validation rules:

rules: {         date_of_birth: { dob: true } } 

but sad part it's not working.

please me out...

thanks in advance.

$.validator.addmethod("dob", function() {     var mindate  = new date();     mindate.setfullyear(mindate.getfullyear() - 16);      var dob =  $('#date_of_birth').val();     if( dob  <= mindate)         return true;     return false; }, "please specify correct dob:"); 

and:

 rules: {     date_of_birth: { required: true, dob: "date_of_birth" }, }, 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -