1

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 ?

Sparky
  • 98,165
  • 25
  • 199
  • 285
P. Sohm
  • 2,842
  • 2
  • 44
  • 77
  • Looks related to http://stackoverflow.com/questions/6906725/unobtrusive-validation-in-chrome-wont-validate-with-dd-mm-yyyy. If so, there are solutions there. – KS15 May 28 '14 at 08:46

0 Answers0