jQuery validation is powerful,easy to use and most widely used client-side form validation. In addition to this you can add custom rules to default rules of jquery validation. This can be done by adding "addMethod" function as per your requirement.

In some case when you are working around dates you need to validate two dates. For e.g if you are working with Start Date and End date than "End Date must be Greater than Start Date". This can be done by javascript by comparing two dates. But if you are using jquery validation than below is the easy and simple way to check that End date is Greater than Start Date or not.

Just copy below code and paste it in to your validation file. Now add "enddate" class to end date textbox , add "startdate" class to startdate textbox. Thats it

$.validator.addMethod("enddate", function(value, element) {
var startdatevalue = $('.startdate').val();
return Date.parse(startdatevalue) < Date.parse(value);
}, "End Date should be greater than Start Date.");

Date.parse will convert string value(form element value) in to javascript date object as javascript we need to compare two dates not two string.

To know more about programming,JavaScript issues,jQuery,MYSQL database,php info,php editor,programming php,Open-source,php help and php script , subscribe to our feed by entering email address below. You will get updates via email about every tutorial posted on this site . It will not take more than a sec.

Enter your email address:
 
Feel free to ask any question. Just leave your comment below and we will answer your comment with in 24 hours.
rax rss jQuery validation : End date should be Greater than Start date  rax twitter jQuery validation : End date should be Greater than Start date  rax facebook jQuery validation : End date should be Greater than Start date  rax myspace jQuery validation : End date should be Greater than Start date