<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<form action="" method="post">
			用户名:<input type="text" name="" id="user" value="" />
			密码: <input type="password" name="" id="psw" value="" />
			<input type="button" name="" id="" value="提交" onclick="pass()"/>
			<input type="reset" value="重置"/>
		</form>
		
		<script type="text/javascript">
			function $(id){
				return document.getElementById("psw")
			}
			function pass(){
			var password = document.getElementById("psw").value;
				if(password.length<6){	
					alert("输入的密码必须大于六位")
					return;}else{
						var count =0
						for (var i=0;i<password.length;i++) {
							if((password[i]>='a' && password[i]<='z')||(password[i]>='A' && password[i]<='Z')){
								count++;
							}
						}
						if(count>=2){
							alert("输入合法")
						}else{
							alert("密码必须含有两位字母两位字母")
						}
					}
			alert("用户名是:"+(document.getElementById("user").value) + "密码是:"+(document.getElementById("psw").value))
			
			}
		</script>
	</body>
</html>

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐