jQuery Validation: Changing Rules Dynamically

后端 未结 10 855
栀梦
栀梦 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:10

    If you want to call validate again with new settings (rules,messages ... etc.) call

    $('#formid').removeData('validator')
    

    This will remove validation for the form then initialize it again with the new settings

提交回复
热议问题