I'm trying to display message that if no checkbox is checked . I'm using javvascript rules and messages
<form method="post" enctype="multipart/form-data name="english_registration_form" id="english_registration_form" >
<div class="col-sm-12 inputgrp2 mstatu">
<label class="labelclass">Marital Status*</label>
<div id="result"></div>
<span id="chkMaritalStatus" class="multiChkBox" >
<div class="col-md-2 col-sm-3 col-xs-12">
<input type="checkbox" name="chkmstatus[]" value="Never Married required">
<label>Never Married</label>
</div>
<div class="col-md-2 col-sm-3 col-xs-12">
<input type="checkbox" name="chkmstatus[]" value="Awaiting Divorce" id="chkchild" required>
<label >Awaiting Divorce</label>
</div>
<div class="col-md-2 col-sm-3 col-xs-12">
<input type="checkbox" name="chkmstatus[]" value="Seperated" id="chkchild2" required>
<label >Seperated</label>
</div>
<div class="col-md-2 col-sm-3 col-xs-12">
<input type="checkbox" name="chkmstatus[]" value="Widow/Widower" id="chkchild3" required>
<label>Widow/Widower</label>
</div>
<div class="col-md-2 col-sm-3 col-xs-12">
<input type="checkbox" name="chkmstatus[]" value="Divorced" id="chkchild4" required>
<label >Divorced</label>
</div>
<div class="col-md-2 col-sm-3 col-xs-12">
<input type="checkbox" name="chkmstatus[]" value="Any" id="chkchild5" required>
<label>Any</label>
</div>
</span>
</div>
<input type='submit' class='btn btn-finish btn-fill btn-success btn-wd' name='finish' value='Finish' />
</form>
And this is my js
var $validator = $('.wizard-card form').validate({
rules: {
'chkmstatus[]': {required: true},
/*chkmstatus: {
required: function(elem)
{
return $("input.select:checked").length > 0;
}
},*/
},
messages: {
chkmstatus[]: "You must check at least 1 box",
}
});
I was trying to keep it as simple as possible and found this example here on site point but it doesn't seem to work how i'm using it.