How to remove validation error from HTML5 input?

html, javascript, validation

Solution

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.

Problem

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?

Original source

Related problems