Do some simple checkbox (at least two checkbox) validation using AngularJS. I have tried my best. This radio button codes working succesfully.
<p>
<label>Gender</label>
<input class="css-checkbox" type="radio" value="male" id="male" name="gender" ng-model="gender" ng-required="!gender"/> <label for="male" class="css-label radGroup1">M</label>
<input class="css-checkbox" type="radio" value="female" id="female" name="gender" ng-model="gender" ng-required="!gender"/> <label for="female" class="css-label radGroup1">F</label>
<span class="error" ng-messages="contact_form.gender.$error">
<span ng-message="required" ng-show="contact_form.gender.$error.required && contact_form.gender.$dirty">At least one must be selected</span>
</span>
</p>
I have tried this same thing in checkbox type. But, it won't work. I'm new to AngularJS.
<p class="checkbox">
<label class="skill">Skills</label>
<label for="certified_plumber"><input type="checkbox" name="certified_plumber" id="certified_plumber" /><span>Certified Plumber</span></label>
<label for="carpentry_experience"><input type="checkbox" name="carpentry_experience" id="carpentry_experience" /><span>Carpentry Experience</span></label>
<label for="certified_electrician"><input type="checkbox" name="certified_electrician" id="certified_electrician" /><span>Certified Electrician</span></label>
<label for="bartending_experience"><input type="checkbox" name="bartending_experience" id="bartending_experience" /><span>Bartending Experience</span></label>
<label for="food_hygiene_certificate"><input type="checkbox" name="food_hygiene_certificate" id="food_hygiene_certificate" /><span>Food Hygiene Certificate</span></label>
<label for="first_aid_course"><input type="checkbox" name="first_aid_course" id="first_aid_course" /><span>First Aid Course</span></label>
<label for="forklift_drive_certificate"><input type="checkbox" name="forklift_drive_certificate" id="forklift_drive_certificate" /><span>Forklift Drive Certificate</span></label>
<label for="drivers_license"><input type="checkbox" name="drivers_license" id="drivers_license" /><span>Driver's License (Type B)</span></label>
<span>Thick off the skills / prerequisite you have</span>
<span class="error" ng-messages="contact_form.skills.$error">
<span ng-message="required">At least select two skills</span>
</span>
</p>
Aucun commentaire:
Enregistrer un commentaire