求大神帮忙写一个js,可以让这个注册页面实现“密码”和“确认密码”一致性的判断。感谢感谢

<body><br/><br/> <center><form action="" method="post"> <label for="username">用户名:</label><input type="text" name="username" placeholder="请 输 入 用 户 名" id="box-name" class="txt" onfocus="this.value=''" /><br/> <label for="passsword">密码:</label><input type="password" name="password" placeholder="请 输 入 密 码" id="box-pass" class="txt" onfocus="this.value=''"/><br/> <label for="repasssword">确认密码:</label><input type="password" name="repassword" placeholder="请 再 次 输 入 密 码" id="box-repass" class="txt" onfocus="this.value=''"/><br/><br/> <input type="submit" id="btn" value="注 册"onmouseover="this.style.backgroundColor='#FF8D00'" onmouseout="this.style.backgroundColor='#FC5628'"> </form></center></body></html>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body><br/><br/>
<center>
<form action="" method="post">
<label for="username">用户名:</label>
<input type="text" name="username"
placeholder="请 输 入 用 户 名" id="box-name"
class="txt" onfocus="this.value=''"/><br/>
<label for="passsword">密码:</label>
<input type="password" name="password" placeholder="请 输 入 密 码" id="box-pass"
class="txt" onfocus="this.value=''"/><br/>
<label for="repasssword">确认密码:</label><input
type="password" name="repassword" placeholder="请 再 次 输 入 密 码" id="box-repass" class="txt"
onfocus="this.value=''"/><br/><br/>
<input type="button" id="btn" value="注 册"
onmouseover="this.style.backgroundColor='#FF8D00'"
onmouseout="this.style.backgroundColor='#FC5628'"
onclick="check()"
>
</form>
</center>
<script>
function check(){
var form = document.getElementsByTagName("form")[0]
var password = document.getElementById("box-pass").value
var rePassword = document.getElementById("box-repass").value
if(password !== rePassword && password !== ''){
alert("确认密码与密码不一致!")
} else {
form.submit()
}
}
</script>
</body>
</html>
</html>
温馨提示:答案为网友推荐,仅供参考

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网