bootstrap-validator icon indicating copy to clipboard operation
bootstrap-validator copied to clipboard

How can I know the form is valid success?

Open ensignwy opened this issue 7 years ago • 4 comments

because I use button but not submit,here is my code: $('#form').validator('validate'); dictionaryApi.saveOrUpdate({ //call this api to save the entity })
But when the form is invalid,it's still can save success,so I want to know if the form is valid,if not,I will return the function.Just like the formvalidation,the is a function named isValid(), isValid(): Boolean — Check the form validity. Can you help me?thanks so much.

ensignwy avatar Dec 03 '17 10:12 ensignwy

$('#form').validator('validate'); // Execute the validation if($('form').data('bs.validator').validate().hasErrors()) { // error goes here } else { // No errors do something.. }

Use the above code to handle the validation. This should be definitely placed in the docs to make it easier for people to find.

krux20 avatar Dec 08 '17 09:12 krux20

@krux20 Thank you so much,It's helpful

ensignwy avatar Dec 09 '17 07:12 ensignwy

@krux20 Thank you!

wchao0615 avatar Jan 10 '18 02:01 wchao0615

@krux20 Thank you!

murphywuwu avatar Mar 01 '18 03:03 murphywuwu