I am new to angular js and want to validate a field on blur. As i am entering the value the directive is called and is validating the entered value. i want this to happen on -blur. I have already user on-blur in the html for calling some other function.
Below is the directive :
app.directive("emailCheck", function(){
return {
require: 'ngModel',
link: function (scope, elm, attrs, ctrl) {
ctrl.$parsers.unshift(function (viewValue, $scope) {
var emailPattern = /\S+@\S+\.\S+/;
var isEmailValid = emailPattern .test(viewValue)
ctrl.$setValidity('emailFormat', isEmailValid);
return viewValue;
})
}
};
});
How do i check for on blur event here?
Thanks in advance.