Created
October 22, 2015 16:44
-
-
Save jasonneylon/313cb475b3acb6856c9c to your computer and use it in GitHub Desktop.
Example of submitting form and validating javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// When submitting the form we use standard jquery validation | |
$form.submit(function handleSubmit(ev) { | |
// call the React address component instance and ask it to validate itself and return any errors | |
const errors = addressInstance.validate(); | |
// if there are errors cancel the form submit | |
if(errors.length > 0) { | |
ev.preventDefault(); | |
} | |
.... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment