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
Jochem
Jochem•2y ago
required validation runs on submit, you're preventing the submit using event.preventDefault();
Avinash
AvinashOP•2y ago
oh.. is there a way around to fix this without validating via js? 🤔
Jochem
Jochem•2y ago
you could try hooking into the submit event on the form instead of the click on the button, I'm not 100% sure though
Want results from more Discord servers?
Add your server