Reputation: 1800
Have a form which includes a jQuery Datepicker. The date format is in the UK format (day/month/year) however the datepicker keeps failing the validation if the first number, which should be the day is greater than 12 suggesting it's trying to validate against the US format and therefore seeing the day as a month. In chrome this stops the form being submitted. Code below is the js used to initialise the datepicker:
$(".datepicker").datepicker({
showOn: "button",
buttonImage: "/Images/calendar.gif",
buttonImageOnly: true,
dateFormat: "dd/mm/yy"
});
An example date that should pass validation but doesn't would be 31/07/2015
I'm equally happy to remove the validation if it can not be made to validate correctly.
Upvotes: 1
Views: 1097
Reputation: 2775
Make sure that there isn't any other client-side/server-side validation kicking in, I suspect that the JQuery Datepicker dateFormat is a red herring.
Upvotes: 1
Reputation: 1390
I do not believe your issue is in fact with the format of the date.
Take a look at the link here: http://api.jqueryui.com/datepicker/#utility-formatDate
If you notice, it says you can use any combination of the formats. I believe this to be a validation issue elsewhere and not the initialization of the datepicker. If the datepicker were at fault, it would not input the date in the proper format, even before validation.
Check your date field that you applied this to. You may need to format the date explicitly for that input
field so that it will accept your datepicker's format
Upvotes: 0