pwdCheck(str){
var reg=/^[a-zA-Z0-9]{6,16}$/;
if(reg.test(str)==true)
return true;
else{
document.getElementById("str2").innerText=" 密码格式不正确!";
}
}
这个函数前边 没有写 function
var reg=/^[a-zA-Z0-9]{6,16}$/;
if(reg.test(str)==true)
return true;
else{
document.getElementById("str2").innerText=" 密码格式不正确!";
}
}
这个函数前边 没有写 function
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href=" <%=basePath%>">
<title>My JSP 'index.jsp' starting page </title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript">
function isEmail(str){
var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/;
if(reg.test(str)==true)
return true;
else{
document.getElementById("str1").innerText=" 邮箱地址格式不正确!";
}
} function hide1(){
document.getElementById("str1").innerText="";
}
function pwdCheck(str){ //----------------------------function....
var reg=/^[a-zA-Z0-9]{6,16}$/;
if(reg.test(str)==true)
return true;
else{
document.getElementById("str2").innerText=" 密码格式不正确!";
}
} function hide2(){
document.getElementById("str2").innerText="";
}
</script>
</head>
<body>
<form>
<table>
<tr height="100pt">
<td>邮箱地址: </td>
<td> <input type="text" id="eml" onblur="isEmail(this.value)" onfocus="hide1()"/> </td>
<td> <div id="str1">
</div> </td>
</tr>
<tr height="50pt">
<td>密码: </td>
<td> <input type="password" id="pwd1" onblur="pwdCheck(this.value)" onfocus="hide2()"/> </td>
<td> <div id="str2">
</div> </td>
</tr>
<tr height="50pt">
<td> <strong> <em>密码由数字和英文字母组成,长度在6-16位之间 </em> </strong> </td>
</tr>
<tr>
<td>确认密码: </td>
<td> <input type="password" id="pwd2" onblur=""/> </td>
</tr>
</table>
</form>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href=" <%=basePath%>">
<title>My JSP 'index.jsp' starting page </title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript">
function isEmail(str){
var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/;
if(reg.test(str)==true)
return true;
else{
document.getElementById("str1").innerText=" 邮箱地址格式不正确!";
}
}
/*
加个参数变量就可以了,onfocus事件直接传参
*/
function hide(sId){
document.getElementById(sId).innerText="";
}
function pwdCheck(str){ //----------------------------function....
var reg=/^[a-zA-Z0-9]{6,16}$/;
if(reg.test(str)==true)
return true;
else{
document.getElementById("str2").innerText=" 密码格式不正确!";
}
}
</script>
</head>
<body>
<form>
<table>
<tr height="100pt">
<td>邮箱地址: </td>
<td> <input type="text" id="eml" onblur="isEmail(this.value)" onfocus="hide('str1')"/> </td>
<td> <div id="str1">
</div> </td>
</tr>
<tr height="50pt">
<td>密码: </td>
<td> <input type="password" id="pwd1" onblur="pwdCheck(this.value)" onfocus="hide('str2')"/> </td>
<td> <div id="str2">
</div> </td>
</tr>
<tr height="50pt">
<td> <strong> <em>密码由数字和英文字母组成,长度在6-16位之间 </em> </strong> </td>
</tr>
<tr>
<td>确认密码: </td>
<td> <input type="password" id="pwd2" onblur=""/> </td>
</tr>
</table>
</form>
</body>
</html>