I have a form with multiple inputs and I need to validate them on a button click.
The problem I'm having is if there is more than one required field it seems call to valid()
validates only the first. Other fields are omitted.
$(function() {
//simple example 1
//click event for first button
$('#btn').click(function() {
$("#form1").valid(); //validate form 1
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.10.0/jquery.validate.min.js"></script>
<form id="form1" name="form1">
Field 1: <input id="field1" type="text" class="required" />
<br/>Field 2: <input id="field2" type="text" class="required" />
<div>
<input id="btn" type="button" value="Validate" />
</div>
</form>
Associated jsfiddle here