I have a group of checkboxes which are the days of the week. If the user clicks the submit button and no checkboxes have been checked, I want to display an error message. Below is the HTML code I'm using.
<div ng-repeat="item in days">
<md-checkbox ng-required="daysSelected.length == 0" ng-checked="dayExists(item, daysSelected)" ng-click="toggleWeekdays(item, daysSelected)" name="daysOfWeek"></md-checkbox>
</div>
<div flex ng-messages="addEditForm.daysOfWeek.$error" ng-if="addEditForm.$submitted">
<div ng-message="required">Please select a day.</div>
</div>
Aucun commentaire:
Enregistrer un commentaire