为什么我点击提交按钮没有反应呢?我已经将行为面板里的onSubmit 后填写了 return checkFormDate()了。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="/style/style.css" rel="stylesheet" type="text/css" />
<script language="javascript">
function checkFormDate(){
if(form1.txtUsername.value==" "){
alert("用户名不能为空");
form1.txtUsername.focus();
return false;
}
if(form1.txtPassword.value==" "){
alert("密码不能为空");
form1.txtPassword.focus();
return false;
}
if(form1.txtRePassword.value==" "){
alert("请再次输入密码");
form1.txtRePassword.focus();
return false;
}
if(form1.txtBirthdate.value==" "){
alert("出生日期不能为空");
form1.txtBirthdate.focus();
return false;
}
}
</script>
</head>
<body>
<?php require_once("menu.php");?>
<div  class="style1">
<table>
<th>注册新会员</th>
</table>
<form method="post" name="form1" onsubmit="return checkFormDate();" align="center">
 用户名:<input type="text"  name="txtUsername" /><br />
  性别:<input type="radio" name="sex" value="man" checked="checked"/>男
     <input type="radio"  name="sex" value"wonmen" />女<br />
  密码:<input type="text"  name="txtPassword"/><br />
确认密码:<input type="text"  name="txtRePassword"/><br />
出生日期:<input type="text"  name="txtBirthdate"/><br />
安全问题:<input type="text" /><br />
  答案:<input type="text" /><br />
电子信箱:<input type="text" /><br />
自我介绍:<textarea rows="3" ></textarea><br />   &nbsp; 
<input name="submit" type="submit"  value="提交" />    
<input name="reset" type="reset"  value="重置" />
</form>
</div>
</body></html>

解决方案 »

  1.   


    function checkFormDate(){  
    if(document.form1.txtUsername.value==""){
    alert("用户名不能为空");
    document.form1.txtUsername.focus();
    return false;
    }
    if(document.form1.txtPassword.value==""){
    alert("密码不能为空");
    document.form1.txtPassword.focus();
    return false;
    }
    if(document.form1.txtRePassword.value==""){
    alert("请再次输入密码");
    document.form1.txtRePassword.focus();
    return false;
    }
    if(document.form1.txtBirthdate.value==""){
    alert("出生日期不能为空");
    document.form1.txtBirthdate.focus();
    return false;
    }}
      

  2.   

    你少了document.forms[0].名称.value判断