0

大家好,我遇到了 jquery 验证插件的问题。 每当我单击按钮提交表单时,代码在EI版本chrome和 FF版本中都可以正常工作Opera10.0.xx23.xx

     <script src="style/js/jquery.js"></script>
    <script src="style/js/jquery.validate.js"></script>
<script type="text/javascript" src="style/js/jquery.form.js"></script>
      <script type="text/javascript">
      $(document).ready(function(){
            var kosh = document.getElementById("username").value;
            $("#form").validate({
                rules:{
                    full_name:"required",
                    user_name:"required",
                    secret:"required",
                    user_email:{
                            required:true,
                            email: true
                        },
                    pwd:{
                        required:true,
                        minlength: 8
                    },
                    cpwd:{
                        required:true,
                        equalTo: "#pwd"
                    },
                    gender:"required",
                    privacy:"required"
                },
                messages:{
                    full_name:"Enter your first and last name",
                    user_name:"Please Chose a Username",
                    secret:"Your Secret Word Can't Be Empty",
                    user_email:{
                        required:"Enter your email address",
                        email:"Enter valid email address"
                    },
                    pwd:{
                        required:"Enter your password",
                        minlength:"Password must be minimum 8 characters"
                    },
                    cpwd:{
                        required:"Enter confirm password",
                        equalTo:"Password and Confirm Password must match"
                    },
                    gender:"Select Gender",
                    privacy:"Select How you like to share your photos with others"
                },
                errorClass: "help-inline",
                errorElement: "span",
                highlight:function(element, errorClass, validClass) {
                    $(element).parents('.control-group').addClass('error');
                },
                unhighlight: function(element, errorClass, validClass) {
                    $(element).parents('.control-group').removeClass('error');
                    $(element).parents('.control-group').addClass('success');
                }
            });         
$('document').ready(function()
{
$('#form').ajaxForm( {
target: '#preview', 
success: function() { 
$('#formbox').slideUp('fast'); 
} 
}); 
$('#loginForm').ajaxForm( {
target: '#preview', 
success: function() { 
$('#formbox').slideUp('fast'); 
} 
});
});

        });
      </script>

我的表格如下

          <form action="func/login.php" id="loginForm" name="loginForm" method="post" class="navbar-form pull-right">

          <input required class="input-large" name="user" placeholder="Your Username..." type="text">
          <input  required type="password" name="pass"  placeholder="Your Password" class="input-large">
        <button class="btn btn-success">Login !</button>
        <a href="reset.php"><span style="color:#fff; position:relative; top:3px; align:center; font-family:verdana;padding:3px; font-size:10px">Forgot Password?</span></a>
      </form>

假设我输入了错误的用户名和密码,它实际上会返回结果,但是只要用户名和密码正确,它就不会从 php 脚本中得到结果,如果用户名和密码正确,它会自动加载,index.php但不会加载它但我已经登录了,如果我index.php在 url 栏输入

4

1 回答 1

0

通过替换来修复它

echo'<meta http-equiv="refresh" content="0;URL=index.php">';

echo'<script>document.location.href="index.php"</script>';

我不知道为什么 FF 和 IE 不接受元标记

于 2013-09-07T10:13:11.323 回答