0

Im using jQuery.validity plugin to validate PHP form.

I need to validate whether the input date format is in dd-MMM-yyyy, but the plugin default is mm/dd/yyyy.

When I use this code,

$("#txtFromDate")                           
            .require()                       
            .match("date")                   
            .lessThanOrEqualTo(new Date()); 

it asks to enter date in its default format.

How to change the input date format to dd-MMM-yyyy (eg: 01-FEB-2012)?

Charles
  • 50,943
  • 13
  • 104
  • 142
Nalaka526
  • 11,278
  • 21
  • 82
  • 116
  • Seems more of a jQuery question with the plugin since you seem to want to check it client side - if you want to check it server side (ie. after hitting submit) then use PHP – MrJ Feb 12 '12 at 16:42

1 Answers1

0

I found this code to change the date format of input string for jQuery.validity plugin

$.extend($.validity.patterns, {
    date:/^\d\d-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)(-\d{4})?$/
});

NOTE: I had to remove the checking of the input date with current date .lessThanOrEqualTo(new Date()); as it always returned false. It seems above code does not change the format for the current date checking...

Nalaka526
  • 11,278
  • 21
  • 82
  • 116