<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>
<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>