当前位置 : 主页 > 网页制作 > Bootstarp >

Bootstrap Modal中的jQuery验证不起作用

来源:互联网 收集:自由互联 发布时间:2021-06-12
将jQuery验证应用于Modal引导程序它没有任何效果,检查所有包含的库及其顺序,并注意到它们是正确的. Bootstrap:版本3.3.1 jQuery:版本1.11.1 jQuery-validate:版本1.13.1 主编: head titleTitulo/titl
将jQuery验证应用于Modal引导程序它没有任何效果,检查所有包含的库及其顺序,并注意到它们是正确的.

> Bootstrap:版本3.3.1
> jQuery:版本1.11.1
> jQuery-validate:版本1.13.1

主编:

<head>
    <title>Titulo</title>

    <link rel="stylesheet" type="text/css" href="../CSS/StyleSheet.css"/>
    <script type="text/javascript" src="../Bootstrap/js/jquery-1.11.1.min.js"></script>
    <script type="text/javascript" src="../Bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="../datepicker/js/bootstrap-datepicker.js"></script>
    <script type="text/javascript" src="../Jquery-Validate/jquery.validate.min.js"></script>
    <script type="text/javascript" src="../Javascript/ActionJS.js"></script>

    <link rel="stylesheet" type="text/css" href="../Bootstrap/css/bootstrap.min.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="../datepicker/css/datepicker.css" media="screen" />

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
</head>

模态代码(在没有AJAX的情况下加载它的HTML)

<div class="modal fade" id="login_modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <form class="form-horizontal" id="login-form" action="../PHP/ValidateForm.php" method="get">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title span7 text-center" id="myModalLabel"><span class="title">Login</span></h4>
                    </div>
                    <div class="modal-body">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="input_email" class="control-label col-md-3">Your Email (login)</label>
                                <div class="col-md-9">
                                    <input type="email" class="form-control" id="email" name="email" placeholder="Email">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="input_password" class="control-label col-md-3">Password</label>
                                <div class="col-md-9">
                                    <input type="password" class="form-control" id="pass" name="pass" placeholder="Password">
                                </div>
                            </div>
                            <div class="checkbox text-center">
                                <label><input type="checkbox" id="remember_me" name="remember_me">Remember me on this computer</label>
                            </div>
                        </div>
                        <div class="form-group text-center">
                            <div class="col-md-6 col-md-offset-3">
                                <button type="reset" class="btn btn-danger">Reset</button>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                        <button type="submit" class="btn btn-primary" name="login_form_submit" value="Login">Login</button>
                    </div>
                </form>
            </div>
        </div>
    </div>

将标签更改为模态体提交按钮不起作用,并且在此视频中检查它将是正确的位置.

ActionJS代码(验证文件)

$(document).ready(function(){
     $("#login-form").validate({
    rules:{
        name:{
            required:true,
            minLength:8
        },
        pass:"required"
    },
    messages:{
        name:{
            required:"Please provide your Login",
            minLength:"Your Login must be at least 8 characters"
        },
        pass:"Please provide your password"
    }
});

});

你的代码有两个问题……

rules:{
    name:{  // <- no such element
        required:true,
        minLength:8  // <- no such rule
    },
    pass:"required"
},

>你没有name =“name”的输入元素.也许你的意思是邮件.
>没有这样的规则叫minLength.我想你的意思是minlength.

注意:您的消息选项中也存在上述相同的两个问题.

工作演说:http://jsfiddle.net/nk3j4mtu/

网友评论