<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>
<body>
密码<input type="password" id="password" onFocus="passwordShow()" onBlur="passwordCheck()" onKeyUp="passwordCheck()">
<span id="passwordid"></span>
<br>
密码确认<input type="password" id="repassword" onFocus="repasswordShow()" onBlur="repasswordCheck()" onKeyUp="repasswordCheck()">
<span id="repasswordid"></span>
<script type="text/javascript">
function passwordShow(){
var a = document.getElementById("passwordid");
a.innerHTML = "<font color='red' size='2'> 密码长度为6</font>";
}
function passwordCheck(){
var a = document.getElementById("password");
var b = document.getElementById("passwordid");
if(a.value == null|| a.value==""){
b.innerHTML = "<font color='red' size='2'> 密码不为空</font>";
}else if(a.value.length<6){
b.innerHTML = "<font color='red' size='2'> 密码长度错误</font>";
}else{
b.innerHTML = "<font color='blue' size='2'> 密码可以使用</font>";
}
}
function repasswordShow(){
var a = document.getElementById("repasswordid");
a.innerHTML = "<font color='red' size='2'>两次密码必须一致</font>"
}
function repasswordCheck(){
var a = document.getElementById("repasswordid");
var b = document.getElementById("repassword");
var c = document.getElementById("password");
if(b.value == null|| b.value==""){
a.innerHTML = "<font color='red' size='2'> 密码不为空</font>";
}else if(b.value.length<6){
a.innerHTML = "<font color='red' size='2'> 密码长度错误</font>";
}else if(b.value != c.value){
a.innerHTML = "<font color='red' size='2'>两次密码不一致</font>"
}else{
a.innerHTML = "<font color='blue' size='2'>两次密码一致</font>"
}
}
</script>
</body>
</html>
8.3密码校验
最新推荐文章于 2023-09-21 19:14:25 发布