js页面上对输入值验证
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档 </title>
<script type="text/javascript">
function chkall()
{
if(document.getElementById("user").value=="")
{
document.getElementById("chkuser").style.display="block";
return false;
}
else
{
document.getElementById("chkuser").style.display="none";
return true;
}
{
var temp = document.getElementById("email");
//对电子邮件的验证
var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
if(temp.value!="")
{
if(!myreg.test(temp.value))
{
document.getElementById("chkemail").style.display="block";
return false;
}
}
else
{
document.getElementById("chkemail").style.display="none";
return true;
}
}
}
</script>
</head>
<body>
<form name="form1" method="post" action="1.htm">
<table width="422" height="141" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="165"> <input name="email" type="text" id="email" onBlur="return chkall();"> </td>
<td width="156"> <span id="chkemail" style="display:none; ">邮箱地址错误 </span> </td>
</tr>
<tr>
<td> <input name="user" type="text" id="user" onBlur="return chkall();"> </td>
<td> <span id="chkuser" style="display:none; ">请输入 </span> </td>
</tr>
<tr>
<td colspan="2"> <div align="center">
<input type="submit" name="Submit" value="提交" onClick="return chkall();">
</div> </td>
</tr>
</table>
</form>
</body>
</html>
在csdn上看到的一个帖子,但是却没有人回答,谁能说下这个哪里错了,为什么不能显示弹出信息。