mingos
mingos

Reputation: 24502

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?

Upvotes: 3

Views: 4407

Answers (1)

Kyle
Kyle

Reputation: 67194

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.

Upvotes: 4

Related Questions