1000hz / bootstrap-validator

A user-friendly HTML5 form validation jQuery plugin for Bootstrap 3
http://1000hz.github.io/bootstrap-validator
MIT License
2.38k stars 1.07k forks source link

How can I know the form is valid success? #603

Open ensignwy opened 6 years ago

ensignwy commented 6 years ago

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.

krux20 commented 6 years ago

$('#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.

ensignwy commented 6 years ago

@krux20 Thank you so much,It's helpful

wchao0615 commented 6 years ago

@krux20 Thank you!

murphywuwu commented 6 years ago

@krux20 Thank you!