srkirkland / DataAnnotationsExtensions

Validation extensions for DataAnnotations, including optional MVC client validation implementations
https://dataannotationsextensions.apphb.com/
BSD 3-Clause "New" or "Revised" License
308 stars 86 forks source link

Date causes validation issues in chrome in the uk #39

Closed burnalias closed 8 years ago

burnalias commented 12 years ago

I have a datetime field that i had decorated with the date annotation. having that validation caused chrome to not work with date fields (switching the culture info to american for some reason). don't want to even tell you how long it took me before i tried commenting out your attribute and everything started working

this was with the client side validation in asp.net mvc3

ianlekhac commented 12 years ago

Hi, the same thing is happening with me, we have the client side validation failing because the validator is taking the american date format. Working in all browsers except for Chrome

jalamo commented 12 years ago

Hi, I had the same problem and I've fixed using globalize.js (http://github.com/jquery/globalize)

<script src="@Url.Content("~/Scripts/globalize.js")" type="text/javascript">

<script src="@Url.Content("~/Scripts/globalize.culture.en-GB.js")" type="text/javascript"></script>
<script type="text/javascript">
    Globalize.culture("en-GB");
    $.validator.methods.date = function (value, element) {
        return this.optional(element) || Globalize.parseDate(value);
    };