Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/388.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/76.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
Javascript 无法验证引导_Javascript_Jquery_Twitter Bootstrap - Fatal编程技术网

Javascript 无法验证引导

Javascript 无法验证引导,javascript,jquery,twitter-bootstrap,Javascript,Jquery,Twitter Bootstrap,我有以下jquery代码 $().ready(function){ $("#Form").validate({ rules:{ DL:{ minlength:2 } } }); } message:{ DL:{ minlength:"DL should be of at least 5"; } } 需要验证的是字段DL的长度应为

我有以下jquery代码

$().ready(function){
    $("#Form").validate({
        rules:{
            DL:{
                minlength:2
            }
        }
    });

}   
message:{
    DL:{
        minlength:"DL should be of at least 5";
    }
}
需要验证的是字段DL的长度应为5。 下面是html代码

                    <div class="form-group">
                        <label for="exampleInputText">Driving License Number</label><input
                            type="text" class="form-control" id="DL" required>
                    </div>

驾驶执照号码
但是,在单击按钮后,页面似乎没有进行验证,而不是显示消息,页面只是向上滚动。

这是您的解决方案

所有代码都有语法错误


$()
应该是
$(document)

主要问题是规则对象查找元素的名称,而您使用的是元素的id

index.html

<form id="FORM">
  <div class="form-group">
    <label for="exampleInputText">Driving License Number</label><input type="text" class="form-control" name="DL" required>
  </div>
  <input type="submit" value="Validate!">
</form>

猜测这不是你的完整代码,因为它包含一个很大的语法错误。你能告诉我错误在哪里吗?
$()
,通常你把它分配给一个对象/元素;例如
$(document).ready(
ready(function)
-ready应该将一个函数作为参数;例如
.ready(function(){…});
我甚至不知道
消息:{…}
指向什么
$(document).ready(function(){
  $( "#FORM" ).validate({
    rules: {
      DL: {
        required: true,
       minlength: 5
      }
    },
    messages: {
      DL: "DL should be of at least 5"
    }
  });
});