I have a form with some fields.
I check fields with css classes: (if the field is invalid and the user touched it, then enter border-color = red.)
select.ng-invalid.ng-touched, input.ng-invalid.ng-touched,textarea.ng-invalid.ng-touched { border-color: red; }
If the user submits the form without filling out one or more fields, there will be a warning about the danger.
HTML:
<div ng-show="formInvalid> error! </div>
JS:
if ($scope.pniyaForm.$valid) { $scope.formInvalid = false; ..... } else { $scope.formInvalid = true; }
But, if the user submits the form and does not touch any field, the css classes do not affect (since the user did not touch ...)
I want to add a class to the code.
Does anyone have any ideas for an elegant way to do this without writing it to each field separately?
source share