Interactive Card Details Form With HTML,CSS,JS,JQuery
Design comparison
Solution retrospective
I still don't understand how to create the correction feature to stop form from submitting and show warning when form input is not appropriate
Community feedback
- @simeydotmePosted over 2 years ago
To prevent the form from submitting if Validation is not passed, you may use an
onsubmit
event on the<form>
element (<form onsubmit='checkValidation'>
) instead of using aonclick
event on the<button>
... then you can check if the form has not passed validation. You canreturn false
orevent.preventDefault
inside of thecheckValidation
event handler to stop the form from submitting on error.More information can be found on mozdev; https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/submit_event#javascript
Hope that is helpful!
Marked as helpful0@Tegarsetyo6Posted about 2 years ago@simeydotme thank you very much for your help
0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord