简体   繁体   中英

jQuery datepicker validation fail

Have a form which includes a jQuery Datepicker. The date format is in the UK format (day/month/year) however the datepicker keeps failing the validation if the first number, which should be the day is greater than 12 suggesting it's trying to validate against the US format and therefore seeing the day as a month. In chrome this stops the form being submitted. Code below is the js used to initialise the datepicker:

    $(".datepicker").datepicker({
        showOn: "button",
        buttonImage: "/Images/calendar.gif",
        buttonImageOnly: true,
        dateFormat: "dd/mm/yy"
    });

An example date that should pass validation but doesn't would be 31/07/2015

I'm equally happy to remove the validation if it can not be made to validate correctly.

确保没有其他客户端/服务器端验证生效,我怀疑JQuery Datepicker dateFormat是一个红色鲱鱼。

I do not believe your issue is in fact with the format of the date.

Take a look at the link here: http://api.jqueryui.com/datepicker/#utility-formatDate

If you notice, it says you can use any combination of the formats. I believe this to be a validation issue elsewhere and not the initialization of the datepicker. If the datepicker were at fault, it would not input the date in the proper format, even before validation.

Check your date field that you applied this to. You may need to format the date explicitly for that input field so that it will accept your datepicker's format

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM