Override HTML5 validation

JavascriptWeb DevelopmentFront End Scripts

To ignore HTML validation, you can remove the attribute on button click using JavaScript.

Uer removeAttribute() to remove an attribute from each of the matched elements.

<!DOCTYPE html>
         First Name: <input type = "text" id = "fname" value = "Amit" required>
         <input type = "radio" onclick = "dislay('fname')"><br>
         function display(id) {
            document.getElementById(id).value = document.getElementById(id).removeAttribute('required');
Published on 10-Apr-2018 12:20:33