Jquery Datepicker Chrome

前端 未结 6 1223
清歌不尽
清歌不尽 2020-11-27 04:22

When using jQuery UI Datepicker, we encouter a problem when used in Google Chrome: when we enter a date with a day higher than 12, it does not accept it as a valid date, th

6条回答
  •  执笔经年
    2020-11-27 04:50

    user1011138 solution dont work for me since .toLocaleDateString(value) doesn't parse the value string

    here's the solution i came up with => in jquery.validate.js find this function definition: "date: function (value, element)" and replace the code with:

    // http://docs.jquery.com/Plugins/Validation/Methods/date
    date: function (value, element) {
        var d = value.split("/");
        return this.optional(element) || !/Invalid|NaN/.test(new Date((/chrom(e|ium)/.test(navigator.userAgent.toLowerCase())) ? d[1] + "/" + d[0] + "/" + d[2] : value));
    },
    

提交回复
热议问题