JSFiddle - React, Tailwind, and code Playground
by mcgrailm
HTML
<script src="http://www.kinetick.com/JS/jquery.validate.js"></script>
<form id="RequestCreateForm" action="" method="post">
<div class="editor-field">
<input type="checkbox" class="to" name="requestTypeIds2" value="2">Type 2
<input type="checkbox" class="to" name="requestTypeIds1" value="1">Type 1
<input type="checkbox" class="to" name="requestTypeIds3" value="3">Type 3
</div>
<input type="text" name="foo" class="requried" />
<input type="submit" value="submit" />
</form>
JavaScript
$(document).ready(function(){
// Method for verifying that at least one checkbox has been checked
jQuery.validator.addMethod("atLeastOneChecked", function(value, element, params) {
return $('.to:checked').length > 0;
}, jQuery.format("From?"));
// Tell jQuery validation plugin to validate the search form with the proper rules
$("#search_form").validate({
rules: {
'to': {
required: true,
atLeastOneChecked: true
}
},
messages: {
'to': {
required: "To?"
}
}
});
});