Validate two forms when one's submission depends on the other

后端 未结 1 1676
误落风尘
误落风尘 2020-12-07 05:50

I\'m working on this project and am getting stuck with form validation. I have two forms, Form X and Form Y and I wanna use the jQuery validation plugin to implement client-

1条回答
  •  無奈伤痛
    2020-12-07 06:31

    Your ajax belongs inside the submitHandler callback of the Validate plugin. You also need to wrap everything inside a DOM ready hander function to ensure the HTML exists when .validate() is called. You should not need any ajax outside of .validate(), nor should you need any additional click handlers.

    
    

    Documentation: http://jqueryvalidation.org/validate/

    submitHandler (default: native form submit)
    Type: Function()
    Callback for handling the actual submit when the form is valid. Gets the form as the only argument. Replaces the default submit. The right place to submit a form via Ajax after it validated.

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