Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • Don't know why, but the type is set to text, not datetime-local, so there is no HTML5 date validation done. (also see this post why it isn't datetime...) Commented May 22, 2015 at 7:46
  • 1
    Are you using jquery.validate.unobtrusive.js? If so then you would need to use jquery.globalize or modify the $.validator.addMethod() -refer this answer because jquery.validate uses the MM/dd/yyyy format for validating dates (whereas yours is dd/MM/yyyy) Commented May 22, 2015 at 7:58
  • 1
    I tried $.validator.addMethod() but it did not work. may be becuase I am not using any datetimepicker; just a readonly textbox which displays the values. I have included jquery.globalize but cannot remove jquery.validate.unobtrusive.js as it is a bundle used in layout page and I am not confident about what impact it might have on other pages. Commented May 22, 2015 at 9:18
  • 1
    You don't need to remove jquery.validate.unobtrusive.js (jquery.globalize is just on top of that, and jquery.validate.js). The example using $.validator.addMethod() was for the jquery-ui datepicker, but you can easily modify that to parse the textbox to the correct format. However, the easiest solution is to use hidden inputs so that the controls are not validated. Commented May 23, 2015 at 2:51