Friday, October 7, 2016

Jquery dd/MM/yyyy date format validation ASP.NET MVC 4

download the files from
include references to relevant .js files (You can also install it with NuGet packages as well, which is the option I have used.)
<script src="~/Scripts/globalize/globalize.js"></script>
<script src="~/Scripts/globalize/cultures/globalize.culture.en-GB.js"></script>

$(document).ready(function () {
        $.culture = Globalize.culture("en-GB");
        $ = function (value, element) {
            //This is not ideal but Chrome passes dates through in ISO1901 format regardless of locale 
            //and despite displaying in the specified format.

            return this.optional(element)
                || Globalize.parseDate(value, "dd/MM/yyyy", "en-GB")
                || Globalize.parseDate(value, "yyyy-mm-dd");

1 comment:
Write comments
Recommended Posts × +