title: Validate date in dd/mm/yyyy format using JQuery Validate
body: <p>I am taking input of date of birth and date of death. Validation required </p>
  
  <ol>
  <li>date of death should be more than date of birth</li>
  <li>Date format to be dd/mm/yyyy</li>
  <li>Dates to be less than or equal to today.</li>
  </ol>
  
  <p>Validate doesn't work as expected and can't figure out the problem. Please help.</p>
  
  <p><a href="http://jsfiddle.net/mundie/Tf8r5/" rel="noreferrer">Fiddle code</a></p>
  
  <p>JS libraries used </p>
  
  <ol>
  <li>JQuery UI for Calendar/Datepicker</li>
  <li>JQuery validate for form validation</li>
  <li><p>Additional methods for validation library</p>
  
  <pre><code>var today = new Date();
  var authorValidator = $("#itemAuthorForm").validate({
  rules : {
      dateOfBirth : {
          required : false,
          date : true,
          dateITA : true,
          dateLessThan : '#expiredDate'
      },
      expiredDate : {
          required : false,
          date : true,
          dateITA : true,
          dateGreaterThan : "#dateOfBirth"
      }
  },
  onfocusout : function(element) {
      if ($(element).val()) {
          $(element).valid();
      }
  }
  });
  var dateOptionsDOE = {
  maxDate : today,
  dateFormat : "dd/mm/yy",
  changeMonth : true,
  changeYear : true,
  onClose : function(selectedDate) {
      $("#dateOfBirth").datepicker("option", "maxDate", selectedDate);
  }
  };
  var dateOptionsDOB = {
  maxDate : today,
  dateFormat : "dd/mm/yy",
  changeMonth : true,
  changeYear : true,
  onClose : function(selectedDate) {
      $("#expiredDate").datepicker("option", "minDate", selectedDate);
  }
   };
  
  jQuery.validator.addMethod("dateGreaterThan",
  function(value, element, params) {
  if ($(params).val() === "")
      return true;
  
  if (!/Invalid|NaN/.test(new Date(value))) {
      return new Date(value) &gt; new Date($(params).val());
  }
  return isNaN(value) &amp;&amp; isNaN($(params).val())
          || (Number(value) &gt; Number($(params).val()));
          }, 'Must be greater than {0}.');
          jQuery.validator.addMethod("dateLessThan",
          function(value, element, params) {
  if ($(params).val() === "")
      return true;
  
  if (!/Invalid|NaN/.test(new Date(value))) {
      return new Date(value) &lt; new Date($(params).val());
  }
  
  return isNaN(value) &amp;&amp; isNaN($(params).val())
          || (Number(value) &lt; Number($(params).val()));
          }, 'Must be less than {0}.');
          $("#expiredDate").datepicker(
      $.extend({}, $.datepicker.regional['en-GB'], dateOptionsDOE));
          $("#dateOfBirth").datepicker(
      $.extend({}, $.datepicker.regional['en-GB'], dateOptionsDOB));
  </code></pre></li>
  </ol>