8.5总结


<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>

<body>
<form action="跳转到的页面.html"  onSubmit="return onSubmint()">    
    账号:<input type="text" id="username" onFocus="nameShow()" onBlur="nameCheck()" onKeyUp="nameCheck()">
    <span id="namespan"></span>
    
    <br>
    
    密码<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>

	<br>

	<input type="submit" value="提交">
</form>
<script type="text/javascript">
//账号
	function nameShow(){
		var a = document.getElementById("namespan");
		a.innerHTML = "<font color='red' size='2'>用户名不能小于6位</font>";
	}
	function nameCheck(){
		var a = document.getElementById("namespan");
		var b = document.getElementById("username").value;
		if(b.length<6){
			a.innerHTML = "<font color='red' size='2'>用户名长度不对</font>";
			return false;
		}else{
			a.innerHTML = "<font color='blue' size='2'>输入正确</font>";
			return true;
		}
	}
//密码
	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>";
			return false;
		}else if(a.value.length<6){
			b.innerHTML = "<font color='red' size='2'> 密码长度错误</font>";
			return false;	
		}else{
			b.innerHTML = "<font color='blue' size='2'> 密码可以使用</font>";
			return true;
		}
	}
//再次输出密码
	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>";
			return false;
		}else if(b.value.length<6){
			a.innerHTML = "<font color='red' size='2'> 密码长度错误</font>";	
			return false;
		}else if(b.value != c.value){
			a.innerHTML = "<font color='red' size='2'>两次密码不一致</font>";
			return false;
		}else{
			a.innerHTML = "<font color='blue' size='2'>两次密码一致</font>";
			return true;

		}
	}

//确认格式是否都正确
	function onSubmint(){
		var a = nameCheck() && passwordCheck() && repasswordCheck();
		return a;
	}
	
</script>
</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值