Home > Web Front-end > JS Tutorial > body text

Get the js code of all inputs under the form_javascript skills

WBOY
Release: 2016-05-16 17:16:48
Original
957 people have browsed it

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;
}
}
}
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template