jsp页面中输入框的onblur事件没反应?
<scripttype="text/javascript">functionckpwd(){vararg=/^[a-zA-Z0-9]+$/;varpwd=document...
<script type="text/javascript">
function ckpwd(){
var arg=/^[a-zA-Z0-9]+$/;
var pwd=document.getElementById("passWord").value;
if(pwd==null||pwd==""){
document.getElementById("passWord").focus();
document.getElementById("pwd").innerHTML = "<font color='red'><b>密码不能为空!!!</b></font>";
}else if(pwd.length<6){
document.getElementById("passWord").focus();
document.getElementById("pwd").innerHTML = "<font color='red'><b>密码不能小于6位数!!!</b></font>";
}else(!arg.test(pwd)){
document.getElementById("passWord").focus();
document.getElementById("pwd").innerHTML = "请不要输入不能识别的字符!!只能是字母和数字!!!!!!";
}
}
function repwd(){
var pwd=document.getElementById("passWord").value;
var repwd=document.getElementById("repassWord").value;
if(pwd==repwd){
document.getElementById("repwd").innerHTML="";
return true;
}
else{
document.getElementById("repassWord").focus();
document.getElementById("repwd").innerHTML="两次密码不一致!!!!";
return false;
}
}
</script>
</head>
<body>
<form method="post" action="register_success.jsp" onsubmit="return ck()">
<dl>
<dt>密 码:</dt>
<dd><input class="input-text" type="password" name="passWord" id="passWord" onblur="ckpwd()"/><span id="pwd"></span></dd>
<dt>确认密码:</dt>
<dd><input class="input-text" type="password" name="rePassWord" id="rePassWord" onblur="repwd()"/><span id="repwd"></span></dd>
<dd class="button"><input class="input-reg" type="submit" name="register" value="" /></dd>
</dl>
</form>
</div>
</body>
</html> 展开
function ckpwd(){
var arg=/^[a-zA-Z0-9]+$/;
var pwd=document.getElementById("passWord").value;
if(pwd==null||pwd==""){
document.getElementById("passWord").focus();
document.getElementById("pwd").innerHTML = "<font color='red'><b>密码不能为空!!!</b></font>";
}else if(pwd.length<6){
document.getElementById("passWord").focus();
document.getElementById("pwd").innerHTML = "<font color='red'><b>密码不能小于6位数!!!</b></font>";
}else(!arg.test(pwd)){
document.getElementById("passWord").focus();
document.getElementById("pwd").innerHTML = "请不要输入不能识别的字符!!只能是字母和数字!!!!!!";
}
}
function repwd(){
var pwd=document.getElementById("passWord").value;
var repwd=document.getElementById("repassWord").value;
if(pwd==repwd){
document.getElementById("repwd").innerHTML="";
return true;
}
else{
document.getElementById("repassWord").focus();
document.getElementById("repwd").innerHTML="两次密码不一致!!!!";
return false;
}
}
</script>
</head>
<body>
<form method="post" action="register_success.jsp" onsubmit="return ck()">
<dl>
<dt>密 码:</dt>
<dd><input class="input-text" type="password" name="passWord" id="passWord" onblur="ckpwd()"/><span id="pwd"></span></dd>
<dt>确认密码:</dt>
<dd><input class="input-text" type="password" name="rePassWord" id="rePassWord" onblur="repwd()"/><span id="repwd"></span></dd>
<dd class="button"><input class="input-reg" type="submit" name="register" value="" /></dd>
</dl>
</form>
</div>
</body>
</html> 展开
展开全部
不是事件没响应,而是你脚本中存在语法错误,将
}else(!arg.test(pwd)){
改为
}else if(!arg.test(pwd)){
还有,将
var repwd=document.getElementById("repassWord").value;
改为
var repwd=document.getElementById("rePassWord").value;
注意P大写
还有另一处
document.getElementById("rePassWord").focus();
也是将P大写
}else(!arg.test(pwd)){
改为
}else if(!arg.test(pwd)){
还有,将
var repwd=document.getElementById("repassWord").value;
改为
var repwd=document.getElementById("rePassWord").value;
注意P大写
还有另一处
document.getElementById("rePassWord").focus();
也是将P大写
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询