开发者

Jquery Validation without form submission

开发者 https://www.devze.com 2023-01-28 17:13 出处:网络
I have a form, on which I have a button - When the user clicks the button Add, a function is called which adds a new row to a t开发者_Python百科able in the same form, but using javascript.

I have a form, on which I have a button - When the user clicks the button Add, a function is called which adds a new row to a t开发者_Python百科able in the same form, but using javascript.

I have used the jquery validation plugin,the problem I have is that the validation only fires when I use a submit button,but not when my button is clicked, which runs my function.

I understand why this is - The validation plugin wants the form to be submitted.

Is there any way I can cause the validation to run and return its result? My function can then either do nothing if the validation fails, or go ahead and post the user entered data to my function if the validation passes. Obviously I would need to do this without the form actually submitting.

Any help greatly appreciated - I've tried a few ideas I found whilst Googling on this, but nothing has worked so far.

Thank you beforehand.


If you mean http://www.position-absolute.com/articles/jquery-form-validator-because-form-validation-is-a-mess/

if ($j('#Form1').validationEngine({ returnIsValid: true })) {
  //is valid
}

Or if you mean: http://docs.jquery.com/Plugins/Validation

$("#myform").validate({
 submitHandler: function(form) {
   // some other code
   return false;
 }
});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号