One: Form object, verify that two times the input is consistent
<!doctype html>
<meta charset= "Utf-8" >
<title> Untitled Document </title>
<script type= "Text/javascript" >
function Check () {
var form1=document.forms.item (0);
var Passwd=form1.passwd.value;
var Passwd2=form1.passwd2.value;
if (PASSWD!=PASSWD2) {
Error2.innertext= "two times input password inconsistent";
error2.style.display= "inline";
return false;
}
}
</script>
<body>
<form action= "js-12.html" method= "POST" >
<table border= "0" >
<tr><td> Password: </td><td><input class= "style1" type= "password" name= "passwd"
Id= "passwd"/></td></tr>
<tr><td> Confirm Password </td><td><input class= "style1" type= "password" name= "Passwd2"
Id= "Passwd2"/><span style= "display:none;color:red;" id= "Error2" ></span></td></tr>
<tr><td><input type= "Submit" onclick= "return Check ()" value= "Registered user" ></td><td>< Input
Type= "Reset" value= "re-fill"/></td></tr>
</table>
</form>
</body>
Two; set the mouse cursor
<!doctype html>
<meta charset= "Utf-8" >
<title> Untitled Document </title>
<script type= "Text/javascript" >
function SetFocus () {
document.getElementById ("Text1"). focus ();
}
</script>
<body>
<form>
Name:<input type= "text" id= "Text1"/>
<br/>
<input type= "button" onclick= "SetFocus ()" value= "Set Focus"/>
</form>
</body>
Copyright Notice: Bo Master original articles, reproduced please indicate the source. Http://blog.csdn.net/dzy21
JavaScript DOM Programming (6): Common Objects 5