Home  >  Article  >  Web Front-end  >  Get the js code of all inputs under the form_javascript skills

Get the js code of all inputs under the form_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:16:48946browse

Use the collection object elements of form to get value

Copy code The code is as follows:

var form = document.getElementById("dateform");
var a = form.elements.length;//Number of all controls
for (var j=0;jif (form.elements[j].className == "text"){//Control with class="text"
if(form.elements[j].value=="" || form.elements[j] .value==null){
alert("cannot be null");
form.elements[j].focus();
return false;
}
}
}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn