js验证两次输入密码是否一致

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>checkPwd</title>
<meta name="author" content="yangch" />
<!-- Date: 2013-06-20 -->
<script>
function check2pwd() {
if(input1.value != input2.value) {
alert("两次输入密码不一致!")
input1.value = "";
input2.value = "";
}
}
</script>
</head>
<body>
<form action="testaction">
<table>
<tr><td>密码:  
<input type="password" id="input1"></td>
</tr>
<tr><td>重复密码:
<input type="password" id="input2" onblur="check2pwd()" ></td></tr>

</table>
<input type="button" value="test啦!" />
</form>

</body>
</html>

版权声明:本文为ych0108原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。