Disable required validation by JavaScript

前端 未结 7 884
半阙折子戏
半阙折子戏 2020-12-19 02:11

I have a create form to create an object. The create model has some properties that are only visible (.hide, .show()) if a checkbox is checked and that are marked required (

7条回答
  •  孤城傲影
    2020-12-19 02:51

    You can use following JQuery to remove all validation rules of your element

    $('#ElementId').rules('remove');
    

    Same way you can use class name like,

    $('.ElementClassName').rules('remove');
    

    If you want to remove specific rule, do like this

    $('#ElementId').rules('remove', 'required');
    

提交回复
热议问题