简体   繁体   English

jQuery验证插件无法验证整个表单

[英]Jquery Validation plugin not validating entire form

I am trying to validate a form with the jQuery validation plugin. 我正在尝试使用jQuery验证插件来验证表单。 However, I am only getting the validation to work for 1 of the inputs. 但是,我只能使验证对其中一个输入起作用。 Any ideas? 有任何想法吗?

<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.js">     </script>

 <form id="driver-form" class="form-horizontal driver" method="post">
        <div class="form-group">
            <label for="inputName1" class="col-md-2 col-md-offset-2 control-label">First Name</label>
            <div class="col-md-4">
            <input type="text" class="form-control" id="driverFirst" placeholder="First Name" required/>
            </div>
        </div>
        <div class="form-group">
            <label for="driverLast" class="col-md-2 col-md-offset-2 control-label">Last Name</label>
            <div class="col-md-4">
            <input type="text" class="form-control" id="driverLast" placeholder="Last Name" required/>
            </div>
        </div>
        <div class="form-group">
            <label for="inputEmail1" class="col-md-2 col-md-offset-2 control-label">Email</label>
            <div class="col-md-4">
            <input type="email" class="form-control" id="driverEmail" placeholder="Email" required/>
            </div>
        </div>
        <div class="form-group">
            <label for="inputPhone1" class="col-md-2 col-md-offset-2 control-label">Phone Number</label>
            <div class="col-md-4">
            <input type="text" class="form-control" id="driverPhone" placeholder="Phone Number" required/>
            </div>
        </div>

    </form>

javascript: JavaScript的:

 $("#driver-form").validate();

jsfiddle: http://jsfiddle.net/rynslmns/533Yt/ jsfiddle: http : //jsfiddle.net/rynslmns/533Yt/

The validation framework used name attribute, you have not specified it 验证框架使用了name属性,您尚未指定

<input type="text" class="form-control" id="driverFirst" name="driverFirst" placeholder="First Name" required/>

Demo: Fiddle 演示: 小提琴

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM