<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<script type="text/javascript">
function check(){
var code=("idpassword").value; //获取输入的密码
var password="12345678"; //预设密码
if(code==""){ //判断输入是否为空
alert("请输入密码:");
return;
}
else if(code==password){
alert("输入正确!");
}
else if(code!=password){
alert("输入错误!");
return;
}
}
</script>
</head>
<body>
<p>
<form name="form" action="" method="post">
<p>
<label for="textfield">请输入密码:</label>
(12345678)
</p>
<p>
<input type="password" >
</p>
<input type="button" onClick="check()" value="确认" >
</form>
</p>
</body>
</html>