JavaScript DOM Programming (6): Common Objects 5

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.