<html>
<head>
<script language="javascript">
function check()
{
if (this.form1.NickName.value=="")
{
alert("请填写用户名!");
this.form1.NickName.focus();
return false;
}
if (this.form1.Password.value=="" || this.form1.Rpwd.value=="")
{
alert("请填写密码!");
this.form1.Password.focus();
return false;
}
}
</script>
<title></title>
<style type="text/css">
<!--
.style1 {color: #FF0000}
-->
</style>
</head>
<body>
<div align=center>
<form name=form1 action=AddUser.php method=post onsubmit="return check()">
  <table width="600" height="321" border="1" cellpadding="0" cellspacing="1" bordercolor="#8C63A4" bgcolor="#999999">
    <tr align="center">
      <td height="32" colspan="2" bgcolor="#fafafa">公司新员工注册(**表示必须填项)</td>
      </tr>
    <tr> 
      <td align="right" bgcolor="#fafafa"><div align=right>用户名:</div></td>
      <td bgcolor="#fafafa"><input name=NickName type=text id="NickName" size=16>
        <span class="style1">**</span></td>
    </tr>
    <tr> 
      <td align="right" bgcolor="#fafafa"><div align=right>密码:</div></td>
      <td bgcolor="#fafafa"><input name=Password type=password id="Password" size=12>
        <span class="style1">**</span></td>
    </tr>
    <tr>
      <td align="right" bgcolor="#fafafa">密码确认:</td>
      <td bgcolor="#fafafa"><input type="text" name="Rpwd" size=12>
        <span class="style1">**</span></td>
    </tr>
</table>
<p></p>
<input type=submit value="注 册">  <input type=reset value="取 消">
</form>
</div>

解决方案 »

  1.   

    我改过了,还是不行。不检测,就是不执行check()函数。
      

  2.   

    改了function check()
    把最后的
    return true;
    去掉了
      

  3.   

    改为
    <script language="JavaScript" type="text/JavaScript">
    function check()
    {
    if (document.insert_form.NickName.value=="")
    {
    alert("请填写用户名!");
    return false;
    }
    else if (document.insert_form.Password.value=="" || document.insert_form.Rpwd.value=="")
    {
    alert("请填写密码!");
    return false;
    }}
    </script>
      

  4.   

    哎哟,没有认真看你下面的form表单
    不好意思,应该将类似document.insert_form.NickName.value改成document.form1.NickName.value呵呵~~其实楼上两位他们都已经解决了