jonthornton / Datepair.js

A javascript plugin for intelligently selecting date and time ranges, inspired by Google Calendar.
https://www.jonthornton.com/Datepair.js
358 stars 87 forks source link

Jquery validation throws an error with UK time format #72

Closed padders closed 8 years ago

padders commented 8 years ago

Hi,

I hope I'm not doing something stupid here!

I've set the format of all my datepickers to 'dd/mm/yyyy' and then set the format of the datepair to the config below

$('#dateAndTime .date').datepicker({ format: 'dd/mm/yyyy', autoclose: true });

Now when I put in a date such as 16/03/2016 where the day is higher than 12 (as there are only 12 months) I get a 'Please enter a valid date' error.

I'm assuming JQuery is trying to validate the date using the US format of mm/dd/yyyy but I can't for the life of me figure out how to change that, or even if it's possible.

padders commented 8 years ago

Note that the validation works fine when all the datepickers and datepair are set to 'mm/dd/yyyy'. Unfortunately living in the UK the client isn't happy with that.

jonthornton commented 8 years ago

Datepair doesn't try to parse dates itself - it relies on the parseDate option, which defaults to asking the datepicker plugin for the date. If you post a jsFiddle or some other working example I might be able to help, but this sounds like an issue with the datepicker and not datepair.

padders commented 8 years ago

Hi Jon, yeah I came to that conclusion myself. I ended up updating the jquery date validation manually which seems to work fine. Thanks for the response :)