<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>Document</title>
</head>
<body>
<input type="password" id="p1"/>
<input type="password" id="p2"/>
<input type="submit" onclick="sub();"/>
</body>
<script>
function sub() {
var p1 = document.getElementById('p1'),
p2 = document.getElementById('p2');
if(!p1.value) {
//判断两个密码不为空
alert('原密码未填写');
return false;
}else if(p1.value !== p2.value) {
//判断两个不相同
alert('两次密码不相同');
return false;
}
alert('密码相同');
}
</script>
</html>