UncleCoder.com

UncleCoder.com

Free programming examples and instructions

Remove required attribute of all text controls

How to remove required attribute of all text controls

by Athil


Posted on 10 Jun 2017 Category: Javascript Views: 519

Edited on 10 Jun 2017


Hi, Here I am going to show how to remove required attribute of all Text controls using javascript

 function removeallrequiredfields() {

 var x = document.getElementsByTagName("INPUT");
        var y = [];
        for (var cnt = 0; cnt < x.length; cnt++) {
            if (x[cnt].type == "text" || x[cnt].type == "email" || x[cnt].type == "email" == "password") {
                y.push(x[cnt]);
                document.getElementById(x[cnt].id).required = false;
            }          
        }
        var u = document.getElementsByTagName("textarea");
        var v = [];     
        for (var cnt = 0; cnt < u.length; cnt++) {
            
                document.getElementById(u[cnt].id).required = false;   
        }
    }


Leave a Comment:


Advertisement