jQuery disable rule validation on a single field

前端 未结 5 2018
说谎
说谎 2020-11-28 04:35

I am using MVC to create forms that are generated at runtime. For validation, I am trying my hand at the jQuery validation library which is very convenient to use. I have th

5条回答
  •  甜味超标
    2020-11-28 04:48

    You can remove a rule from a single field by doing the following:

     $("#field").rules('remove', 'required');
    

    Where the second parameter is the rule name. I also remove the attribute associated with this rule to avoid any confusion:

     $("#field").removeAttr('required');     
    

提交回复
热议问题