If you do not want to use datetime picker:
Problems with client validation can occur due to an MVC error (even in MVC 5) in jquery.validate.unobtrusive.min.js, which does not accept a date / date format. . Unfortunately, you must solve this manually.
My final decision:
You should enable this before:
@Scripts.Render("~/Scripts/jquery-3.1.1.js") @Scripts.Render("~/Scripts/jquery.validate.min.js") @Scripts.Render("~/Scripts/jquery.validate.unobtrusive.min.js") @Scripts.Render("~/Scripts/moment.js")
You can install moment.js using:
Install-Package Moment.js
And then you can finally add a fix for the date format syntax:
$(function () { $.validator.methods.date = function (value, element) { return this.optional(element) || moment(value, "DD.MM.YYYY", true).isValid(); } });
lukyer
source share