Use document.querySelectorAll("input[type=text]")
to get the array with all inputs of type "text". You need to iterate through them and validate.
Also note that you will probably want to use something like #container_id input[type=text]
to make sure you won't get any nodes that you don't need.
Here is a sample of how your validation should look:
var nodes = document.querySelectorAll("#container_id input[type=text]");
for (var i=0; i<nodes.length; i++)
if (nodes[i].value == "" || !/[0-9.]+/.test(nodes[i].value))
return "invalid.";
return "valid";
Something like that:
var inp = document.getElementsByTagName('input');
for(var i in inp){
if(inp[i].type == "text"){
if(!/^\d{1,}$/.test(inp[i].value)){
alert('Invalid value detected');
inp[i].focus();
break;
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With