I have a form field that is required and email type. I want the form validation work when I lose focus from my field, so I am using: ng-model-options="{ updateOn: 'blur' }"
example:
<input class="sng-size-input" type="email" required
ng-keyup="clearValidation(emailform.email_interface_form,emailform.email_interface_form.fromAddress)"
ng-model="emailSelectedValue.fromAddress" name="fromAddress"
ng-model-options="{ updateOn: 'blur' }"
value="{{emailSelectedValue.fromAddress}}"
ng-disabled="!emailSelectedValue.enabled" id="emailFromAddress">
<span class="sng_form_error"
ng-show="emailform.email_interface_form.fromAddress.$error.email"
data-i18n="Not Valid e-mail"> </span> <span
class="sng_form_error"
ng-show="emailform.email_interface_form.fromAddress.$error.required"
data-i18n="Required"></span>
when back to the field and start typing again I want my errors messages to disappear, so I am using:
$rootScope.clearValidation = function(form,field){ field.$setPristine(true);
};
my red css on the field disappears, but the error messages are not. What am I missing?
my css:
.form-validation .ng-invalid.ng-dirty {
border-color: #e94b3b;
}
Thanks,