纯js代码判断密码input文本输入内容是否一致

 

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>	
	</head>
	<body>
	   <form >
	   	 password1:<input type="text" id="a" required="required"/><br />
	     password2:<input type="text" id="b" onblur="check()" required="required"/>
	   	<input type="submit"  value="提交" />
	   </form>
	   <script>
		  function check(){
		  	var password1=document.getElementById("a").value;
			var password2=document.getElementById("b").value;
			if(password1!=password2){
					alert("密码不一致请核查");
			}
		  }
		</script>
	</body>
</html>

猜你喜欢

转载自blog.csdn.net/Boxzhang/article/details/82764807