Jquery Validation插件未验证整个表单

时间:2014-02-01 03:53:54

标签: javascript jquery html css validation

我正在尝试使用jQuery验证插件验证表单。但是,我只是对其中一个输入进行验证。有什么想法吗?

<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:

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

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

1 个答案:

答案 0 :(得分:1)

验证框架使用name属性,您尚未指定

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

演示:Fiddle