0

I can't get it to accept an input, it's just going to the default of mm/dd/yyyy.

$('.customDate').datepicker({ dateFormat: 'dd-mm-yy' }).mask('99/99/9999');

I've tried 'dd-mm-yy' and 'dd-mm-yyyy' with no luck. I've read the documentation.

There are elements with the given class, I checked. The mask is working. All files are present.

That line is the last line in my:

$(document).ready(function () {
});
Brian
  • 83
  • 1
  • 1
  • 6
  • The mask plugin is probably overriding the datepicker. Why are you using different formats? – Barmar Dec 22 '16 at 21:42
  • To add, there are no console errors stopping script execution. – Brian Dec 22 '16 at 21:43
  • Barmar, I'm not, 'yy' is actually a 4 digit year as per the documentation.https://api.jqueryui.com/datepicker/#utility-formatDate – Brian Dec 22 '16 at 21:44
  • But your mask has `/` while `dateFormat` has `-`. – Barmar Dec 22 '16 at 21:44
  • Same result after changing to "/" for both. The delimiter in the formatDate is not what actually sets the delimiter. – Brian Dec 22 '16 at 21:48
  • Can you make an executable stack snippet that demonstrates the problem? – Barmar Dec 22 '16 at 21:51
  • It works in a jsfiddle. :/ https://jsfiddle.net/f026rjqc/ – Brian Dec 22 '16 at 22:01
  • Then something else must be going on in your application. If you can't provide enough to demonstrate the problem, it will be hard for us to figure out what's wrong. – Barmar Dec 22 '16 at 22:02

1 Answers1

1

It was a versioning issue. I updated to the latest version of jquery.datepicker and it worked.

For anyone who comes across this question, this was the end result:

$('.customDate').datepicker({ dateFormat: 'dd/mm/yy' }).mask('99/99/9999');
Brian
  • 83
  • 1
  • 1
  • 6
  • `dateFormat` has worked for years, I don't see how it could be because you were using an old version. Maybe an incompatibility between versions of jQuery and jQuery UI? – Barmar Dec 22 '16 at 22:11
  • And you say dateFormat has worked for years, however this post, http://stackoverflow.com/questions/9888000/jquery-datepicker-format-date-not-working, shows differently. – Brian Dec 23 '16 at 14:11
  • He gave an incorrect format, using uppercase instead of lowercase. Why does that mean it doesn't work? – Barmar Dec 23 '16 at 16:26
  • I take it you didn't read the comments. He had to use format, not dateFormat, to get it to work despite the documentation stating dateFormat is the correct option. – Brian Dec 23 '16 at 17:28
  • That was someone else, not the person who posted the question. My guess is he wasn't using jQuery UI Datepicker, but some other datepicker library with different options. – Barmar Dec 23 '16 at 17:39