mercredi 1 février 2017

Make Checkboxes Required Angular JS

I have a form where users have to answer questions through checkboxes. There are quite few checkboxes and I am using Angular Js in the form to validate it. A basic validation is that all the required fields are filled.

Below is my example code:

<input type="checkbox" name="skills"> IT
<input type="checkbox" name="skills"> Design
<input type="checkbox" name="skills"> Photoshop
<input type="checkbox" name="skills"> Writing

Now I want the checkboxes to be required so from the "skills" checkboxes the user atleast checks 1 box.

I have tried putting the required tag but it didn't seem to work.

Im using Angular to validate my form like so

<button ng-disabled="myForm.$invalid"> Submit </button>

Any idea how I can fix this? If you can working fiddle that would great.




Aucun commentaire:

Enregistrer un commentaire