Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQuery验证在引导程序4中不起作用_Jquery_Jquery Validate_Bootstrap Modal - Fatal编程技术网

jQuery验证在引导程序4中不起作用

jQuery验证在引导程序4中不起作用,jquery,jquery-validate,bootstrap-modal,Jquery,Jquery Validate,Bootstrap Modal,我试图用Bootstrap4和JQuery验证来实现表单验证,但似乎无法实现 “我的表单”显示为模式对话框,如下所示: <div class="modal fade" id="insertWaypointModal" tabindex="-1" role="dialog"> <div class="modal-dialog modal-lg" role="document"> <div class="modal

我试图用Bootstrap4和JQuery验证来实现表单验证,但似乎无法实现

“我的表单”显示为模式对话框,如下所示:

<div class="modal fade" id="insertWaypointModal" tabindex="-1" role="dialog">
            <div class="modal-dialog modal-lg" role="document">
                <div class="modal-content">
                    <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">Insert Unofficial Waypoint</h4>
                    </div>
                    <form id="theForm">
                        <div class="modal-body">
                            <div>
                                <div style="margin-left:23.5%">Latitude</div>
                            </div>
                            <div id="inputs">
                                <input type="text" placeholder="Name" id="name" style="margin-right:10px;width:10%"></input>
                                <input type="text" placeholder="Air way" id="airway" style="margin-right:10px;width:10%"></input>
                                <input type="text" placeholder="Latitude" id="latitude" style="margin-right:10px;width:10%"></input>
                                <input type="text" placeholder="Longitude" id="longitude" style="margin-right:10px;width:10%"></input>
                                <label for="border">Border</label>
                                <input type="radio" id="border" style="margin-right:5px" />
                                <label for="int">International</label>
                                <input type="radio" id="int" style="margin-right:5px" />
                                <input type="text" placeholder="Code" id="countryCode"></label>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
                            <button type="submit" class="btn btn-primary" id="modalSave">Save changes</button>
                        </div>
                    </form>
                </div>

                <!-- /.modal-content -->
            </div>
            <!-- /.modal-dialog -->
        </div>
症状:submitHandler始终被调用,但验证从未发生。确保在jquery.validate和jquery.AddationalMethods之前引用jquery。不知道我做错了什么

您的输入元素都不包含名称。如果要使用此插件,任何考虑验证的元素都必须包含name属性,并且在通过rules对象声明规则时,将引用此名称,而不是id

:

强制:所有需要验证的输入元素都需要一个“name”属性,没有这个属性插件将无法工作。“name”属性对于表单也必须是唯一的,因为这是插件跟踪所有输入元素的方式

没有一个输入元素包含名称。如果要使用此插件,任何考虑验证的元素都必须包含name属性,并且在通过rules对象声明规则时,将引用此名称,而不是id

:

强制:所有需要验证的输入元素都需要一个“name”属性,没有这个属性插件将无法工作。“name”属性对于表单也必须是唯一的,因为这是插件跟踪所有输入元素的方式


@谢谢你的帮助。我真蠢,竟然不看医生correctly@thanks谢谢你的帮助。我真蠢,没有正确阅读文件
$("#theForm").validate({
        rules: {
            airway: {
                required: true,
                minlength: 8
            }
        },
        messages: {
            airway: {
                required: "Please enter some data",
                minlength: "Your data must be at least 8 characters"
            }
        },
        submitHandler: function (form) {
            alert('submitting!');
        }

    });