简体   繁体   中英

Jquery Validation without form submission

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 table 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;
 }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM