I want to display validation error beside each checkbox group for each checkbox group. I have created span element for each and want to display error but its not showing beside checkbox for every checkbox group. instead its showing required error for each checkbox beside 1st checkbox group. How to achieve it?
In bellow image, validation message is showing beside 1st checkbox group.
Here is the Html file,
<div class="other-complain-right">
<ul>
<li>
<input type="checkbox" class="radio" value="1" name="IsBppStandard">
<label>Yes</label>
<input type="checkbox" class="radio" value="1" name="IsBppStandard">
<label>No</label>
<span id="ErrorIsBppStandard"></span>
</li>
<li>
<input type="checkbox" class="radio" value="1" name="IsKycNorm">
<label>Yes</label>
<input type="checkbox" class="radio" value="1" name="IsKycNorm">
<label>No</label>
<span id="ErrorIsKycNorm"></span>
</li>
<li>
<input type="checkbox" class="radio" value="1" name="IsKpcsSystem">
<label>Yes</label>
<input type="checkbox" class="radio" value="1" name="IsKpcsSystem">
<label>No</label>
<span id="ErrorIsKpcsSystem"></span>
</li>
<li>
<input type="checkbox" class="radio" value="1" name="IsIndustryPractice">
<label>Yes</label>
<input type="checkbox" class="radio" value="1" name="IsIndustryPractice">
<label>No</label>
<span id="ErrorIsIndustryPractice"></span>
</li>
<li>
<select>
<option>Select Property</option>
</select>
<input type="text" name="" placeholder="Other">
</li>
</ul>
</div>
Validation function as bellow,
$("#kycFormTab4").validate({
errorLabelContainer: '#ErrorIsBppStandard',
//errorLabelContainer: '#ErrorIsKycNorm',
//errorLabelContainer: '#ErrorIsKpcsSystem',
//errorLabelContainer: '#ErrorIsIndustryPractice',
rules: {
'IsBppStandard': {
required: true,
},
'IsKycNorm': {
required: true,
},
'IsKpcsSystem': {
required: true,
},
'IsIndustryPractice': {
required: true,
}
},
//specify validation error messages
messages: {
'IsBppStandard': {
required: "You must check at least 1 box",
},
'IsKycNorm': {
required: "You must check at least 1 box",
},
'IsKpcsSystem': {
required: "You must check at least 1 box",
},
'IsIndustryPractice': {
required: "You must check at least 1 box",
}
}
//submitHandler: function(form){
// form.submit();
//}
});