if checkbox check validate
by lemon kazi
HTML
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery.form/3.32/jquery.form.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.11.1/jquery.validate.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.11.1/additional-methods.js"></script>
<form id="caller">
<label>Phone:</label>
<input type="text" name="phone" id="phonen" class="form-input" value="" />
<div class="option-group check">
<input type="checkbox" name="check1" id="check1" value="1" />
<label for="check1">
<p>Need a call</p>
</label>
</div>
<input type="submit" value="Submit" />
</form>
JavaScript
jQuery(function ($) {
$('#caller').validate({
rules: {
phone: {
required: {
depends: function () {
return $('#check1').is(':checked')
}
}
}
},
submitHandler: function () {
return false;
}
});
});