jQuery Validation: Changing Rules Dynamically

后端 未结 10 919
栀梦
栀梦 2020-12-07 13:07

I have a single form that, depending on which radio button is clicked (Login or Signup), displays either:

  • email address
  • password

or:

10条回答
  •  不思量自难忘°
    2020-12-07 14:14

    There is an option now to ignore fields bases on selector criteria, such as invisible or disabled, such that you wouldn't have to change your rule set:

    .validate({
      ignore: ":not(:visible),:disabled",
      ...
    

提交回复
热议问题