前台页面   <form name="myform" method="post" action="Register_f.asp" onsubmit="return check_register()">
  <table width="90%" border="0" cellspacing="5" cellpadding="0">
            <tr>
              <td width="17%" height="40" align="right" class="fb">电子邮箱                </td>
              <td width="60%" align="left"><input name="email" id="email" type="text" class="inp" size="30" maxlength="100" onblur="chk_email(this.value)" /><label id="emailInfo"></label></td>
              <td width="23%" align="left"><a href="#" class="blue12link">我没有邮箱</a></td>
            </tr>
            <tr>
              <td height="40" align="right" class="fb">用户名</td>
              <td colspan="2" align="left"><input name="username" id="username" type="text" class="inp" size="30" maxlength="100" onblur="chk_user(this.value)"/><label id="userInfo"></label></td>
            </tr>
            <tr>
              <td height="40" align="right" class="fb">创建密码</td>
              <td colspan="2" align="left"><input name="pass" id="pass" type="password" class="inp" size="30" maxlength="100" onblur="chk_pwd(this.value)"/><label id="pwdInfo"></label></td>
            </tr>
            <tr>
              <td height="40" align="right" class="fb">确认密码</td>
              <td colspan="2" align="left"><input name="querenpass" id="querenpass" type="text" class="inp" size="30" maxlength="100" onblur="chk_repwd(this.value)"/><label id="repwdInfo"></label></td>
            </tr>
            <tr>
              <td height="40" align="right" class="fb">验证码</td>
              <td colspan="2" align="left">&nbsp;</td>
            </tr>
            <tr>
              <td height="40" align="right" class="fb">&nbsp;</td>
              <td colspan="2" align="left"><input name="checkbox" type="checkbox" value="checkbox" checked="checked" />                
                我已看过并同意<a href="#" class="blue12link">《徐州英才网用户相关协议》</a></td>
            </tr>
            <tr>
              <td height="40" align="right" class="fb">&nbsp;</td>
              <td colspan="2" align="left"><input type="image" name="image" src="../images/quick.gif" /></td>
            </tr>
          </table>
  </form>后台function chk_user(value)
{
$('#userInfo').html('');
if(value == '') {
$('#userInfo').html('*用户名为空,请重新输入');
$('#userInfo').css('color','red');
$('#userInfo').focus();
return false;
}
var pattern=/^[a-zA-Z](\w){4,17}$/;
if(!pattern.test(value))
{
$('#username').css('color','red');
$('#userInfo').html('*请重新输入用户名');
$('#userInfo').css('color','red');
$('#userInfo').focus();
return false;
}

}function chk_email(email)
{
$('#emailInfo').html('');
if(email == '') {
$('#emailInfo').html('*请输入你的Email地址');
$('#emailInfo').css('color','red');
$('#emailInfo').focus();
return false;
}
var pattern = /^\w+@[a-zA-Z0-9]+(\.[a-zA-Z]{1,3})(\.[a-zA-Z]{1,3})?$/;
if(!pattern.test(email)) {
$('#email').css('color','red');
$('#emailInfo').html('*你的Email格式错误,请重新输入');
$('#emailInfo').css('color','red');
$('#emailInfo').focus();
return false;


}function chk_pwd(pwd)
{
$('#pwdInfo').html('');
if(pwd == '') {
$('#pwdInfo').html('*请输入密码');
$('#pwdInfo').css('color','red');
$('#pwdInfo').focus();
return false;
} else if (pwd.length<6) {
$('#pwdInfo').html('密码必须大于6个字符,请重新输入');
$('#pwdInfo').css('color','red');
$('#pwdInfo').focus();
return false;
} else if(pwd.length>18) {
$('#pwdInfo').html('密码必须小于18个字符,请重新输入');
$('#pwdInfo').css('color','red');
$('#pwdInfo').focus();
return false;
}
else {
$('#pwd').css('color','green'); $('#pwdInfo').css('color','green');
$('#pwdInfo').html('正确');
}}function chk_repwd(repwd)
{
$('#repwdInfo').html('');
if(repwd == '') {
$('#repwdInfo').html('*请再次输入密码');
$('#repwdInfo').css('color','red');
$('#repwdInfo').focus();
return false;

if ($('#pass').val() != repwd) {
$('#repwdInfo').html('两次输入的密码不一致,请重新输入');
$('#repwdInfo').css('color','red');
$('#repwdInfo').focus();
return false;
}
if( $('#pass').val() == $('#querenpass').val() ){
$('#repwd').css('color','green'); $('#repwdInfo').css('color','green');
$('#repwdInfo').html('正确');
}}
function check_register() {
$('#registerck').html('');
if(chk_user($('#username').val())&& chk_email($('#email').val()) && chk_pwd($('#pass').val()) && chk_repwd($('#querenpass').val())) {
return true;
}else {
$('#registerck').html("信息不完整,请重新填写");
$('#registerck').css('color','red');
return false;
}
}
为空可以验证 ,填写OK 按钮点了也没反应 ~~~

解决方案 »

  1.   

    按钮没看到吗?
    <input type="image" name="image" src="../images/quick.gif" />
      

  2.   


              <form name="myform" method="post" action="Register_f.asp" onsubmit="return check_register()">
              <table width="90%" border="0" cellspacing="5" cellpadding="0">
                <tr>
                  <td width="17%" height="40" align="right" class="fb">电子邮箱                </td>
                  <td width="60%" align="left"><input name="email" id="email" type="text" class="inp" size="30" maxlength="100" onblur="chk_email(this.value)" /><label id="emailInfo"></label></td>
                  <td width="23%" align="left"><a href="#" class="blue12link">我没有邮箱</a></td>
                </tr>
                <tr>
                  <td height="40" align="right" class="fb">用户名</td>
                  <td colspan="2" align="left"><input name="username" id="username" type="text" class="inp" size="30" maxlength="100" onblur="chk_user(this.value)"/><label id="userInfo"></label></td>
                </tr>
                <tr>
                  <td height="40" align="right" class="fb">创建密码</td>
                  <td colspan="2" align="left"><input name="pass" id="pass" type="password" class="inp" size="30" maxlength="100" onblur="chk_pwd(this.value)"/><label id="pwdInfo"></label></td>
                </tr>
                <tr>
                  <td height="40" align="right" class="fb">确认密码</td>
                  <td colspan="2" align="left"><input name="querenpass" id="querenpass" type="text" class="inp" size="30" maxlength="100" onblur="chk_repwd(this.value)"/><label id="repwdInfo"></label></td>
                </tr>
                <tr>
                  <td height="40" align="right" class="fb">验证码</td>
                  <td colspan="2" align="left">&nbsp;</td>
                </tr>
                <tr>
                  <td height="40" align="right" class="fb">&nbsp;</td>
                  <td colspan="2" align="left"><input name="checkbox" type="checkbox" value="checkbox" checked="checked" />                
                    我已看过并同意<a href="#" class="blue12link">《徐州英才网用户相关协议》</a></td>
                </tr>
                <tr>
                  <td height="40" align="right" class="fb">&nbsp;</td>
                  <td colspan="2" align="left"><<input type="image" name="image" src="../images/quick.gif" /><!--加上这个,你再试一试~~~-->
    <<input type="submit" value="提交" name="submit"/>
    /td>
                </tr>
              </table>
              </form>
      

  3.   


    哈哈,对按钮来说,type="submit"的按钮 才会触发表单的onsubmit哦~~~
      

  4.   

    image按钮一样可以提交表单;按照你贴出来的代码,如果页面刷新一下就说明有效了啊,不过楼主所要的反应是什么,预期得出的是什么结果?
      

  5.   

    你用ALERT(); 提示,看进函数没, 如果没进的话,你看在那出问题了
      

  6.   

    进函数了 ,return false; 那里提示,说明没TRUE
      

  7.   

    你的那几个验证函数,里面只有在验证不同过的情况下return false,而通过的话你却没有return true,应该在每个函数末尾加一句 return true
      

  8.   


    function chk_user(value)
    {
        $('#userInfo').html('');
        if(value == '') {
            $('#userInfo').html('*用户名为空,请重新输入');
            $('#userInfo').css('color','red');
            $('#userInfo').focus();
            return false;
        }else {
            $('#userInfo').html('');//当验证通过的情况下,清空提示信息,并返回值
            return true;
        }
        var pattern=/^[a-zA-Z](\w){4,17}$/;
        if(!pattern.test(value))
        {
            $('#username').css('color','red');
            $('#userInfo').html('*请重新输入用户名');
            $('#userInfo').css('color','red');
            $('#userInfo').focus();
            return false;
        }else {
            $('#userInfo').html('');//当验证通过的情况下,清空提示信息,并返回值
            return true;
        }
        return true;//这句执行不到,可以忽略,要上面即可
    }
    onsubmit="return check_register()">//这里不改