Skip to content
This repository has been archived by the owner on Mar 12, 2020. It is now read-only.

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

Open
ensignwy opened this issue Dec 3, 2017 · 4 comments
Open

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

ensignwy opened this issue Dec 3, 2017 · 4 comments

Comments

@ensignwy
Copy link

ensignwy commented Dec 3, 2017

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
Copy link

krux20 commented Dec 8, 2017

$('#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
Copy link
Author

ensignwy commented Dec 9, 2017

@krux20 Thank you so much,It's helpful

@wchao0615
Copy link

@krux20 Thank you!

1 similar comment
@murphywuwu
Copy link

@krux20 Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants