<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function validate(){
var p1=document.getElementById("p1").value;
var p2=document.getElementById("p2").value;
if(p1!=p2){
alert("两次密码不同");
}else{
alert("两次密码相同");
}
}
</script>
</head>
<body>
loginName<input type="text" value="" />
password:<input type="password" value="" id="p1"/>
password:<input type="password" value="" id="p2"/>
<input type="button" value="submit" οnclick="validate();"/>
<button οnclick="validate();">submit</button>
</body>
</html>
转载于:https://my.oschina.net/u/3377023/blog/883927