Enable / Disable using classname [JS]

by karthick Chandran

HTML

<input type="text" name="location[street]" value required />
<input type="text" name="location[city]" value required />
<input type="text" name="location[zip]" value required />
<input type="text" name="location[state]" value required />

JavaScript

var i;
var inputs = document.getElementsByTagName("input");

for (i = 0; i < inputs.length; ++i) {
 var name =  inputs[i].getAttribute("name");
    if(name.indexOf("location") > -1)
    {
    inputs[i].disabled = true;
        console.log(name);
        
    }
}