ASP MVC jquery validation in bootsrap tabs causes an undesired postback

后端 未结 1 1635
旧时难觅i
旧时难觅i 2020-12-18 18:03

I have a form with 3 bootstrap tabs in it. Client Validation works correctly when the tab where the validation error occurs is open an

相关标签:
1条回答
  • 2020-12-18 18:14

    Since two of you tabs are hidden when you submit the form, you need to configure the $.validator to validate hidden elements (which are not validated by default).

    You current use of $.validator.setDefaults({ ignore: "" }); is not correct for jquery version 2.2.0 (I believe that usage was depreciated in version 1.9) and it needs to be

    $.validator.setDefaults({ 
        ignore: [] 
    });
    

    Note: do not add the above inside $(document).ready()

    0 讨论(0)
提交回复
热议问题