Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove validation error from HTML5 input?

A client has a contact form that is submitted using an AJAX callback. After completing the AJAX request, the form fields are cleared.

This is where the problem manifests: the emptied form fields are instantly marked as errorous by the browser.

Is there a way to remove the validation error using JavaScript?

like image 666
mingos Avatar asked Feb 11 '26 15:02

mingos


1 Answers

Don't clear individual values, just use the reset() function on the form element. This clears the form to its original (empty) state and no errors appear.

like image 143
Kyle Avatar answered Feb 13 '26 08:02

Kyle



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!