Clientside validation fails for date format dd/mm/yyyy in jQuery Validate

前端 未结 2 1545
眼角桃花
眼角桃花 2021-01-01 05:10

I am using jQuery Validate plugin for clientside validation in an MVC 5 application. For the date fields cilentside validations fails when using dd/mm/yyyy format. Is there

2条回答
  •  爱一瞬间的悲伤
    2021-01-01 05:36

    Adding to Darin's answer. If you happen to already be using the datepicker plugin from JQuery UI then you can use that date parser instead of creating your own:

    $.validator.methods.date = function (value, element) {
        return this.optional(element) ||  $.datepicker.parseDate('dd/mm/yy', value);
    }
    

提交回复
热议问题