@simeydotme
Posted
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 a onclick
event on the <button>
... then you can check if the form has not passed validation. You can return false
or event.preventDefault
inside of the checkValidation
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 helpful
@Tegarsetyo6
Posted
@simeydotme thank you very much for your help