form validation is not working after adding JS
im using basic inbuilt html form validation to check for the form validity. After js code is added to get the values of these input fields to perform further operation, the validity of the form is not working.
here in codepen if you comment js code and click on Add in form the validations is working
https://codepen.io/avinash-tallapaneni/pen/MWPyvQe
3 Replies
required
validation runs on submit, you're preventing the submit using event.preventDefault();
oh.. is there a way around to fix this without validating via js? 🤔
you could try hooking into the
submit
event on the form instead of the click on the button, I'm not 100% sure though