0

I am trying to validate a form with the jQuery validation plugin. 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:

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

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

1 Answer 1

1

The validation framework used name attribute, you have not specified it

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

Demo: Fiddle

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks. Feel like an idiot, I must have scanned right through it in the documentation. Ill accept your answer shortly
do you know why the select boxes aren't validating?
@RyanSalmons in the fiddle they are getting validated... jsfiddle.net/arunpjohny/N7TwX/4 - you need to assign the value of the default option to empty like <option value="">Year</option>
do you know how to edit the CSS for the validation text? Sorry to keep bugging.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.