I'd like to validate the dateformat in ASP MVC 4 with Unobtrusive jQuery Validation.
My Views/Shared/EditorTemplates/DateTimeNotNullable.cshtml :
@model DateTime
@Html.TextBox("", Model.ToShortDateString(), new { maxlength = 10, @class = "editor-datetime", style = "width: 150px" })
<script type="text/javascript">
if (typeof (jQuery) == 'function')
{
$(function () {
if ($.datepicker) {
$("#@this.ViewData.TemplateInfo.GetFullHtmlFieldId("")").datepicker();
}
});
}
</script>
But when I put a french date format (dd/MM/yy) ex: 18/04/2013, I always have a valiation error.
I already tryied to use the Microsoft Globalization library, it worked but I had a regression on the validation of the decimal format. Do you have simple javascript to correct that behaviour ?