I am using Angular for form validation.
Here is what I use - plunker-edit I have taken this code from Angularjs documentation - Binding to form and control state Hav
As ReCaptcha suggested I ended up creating a custom validation directive
var app = angular.module('login-form', []);
var INTEGER_REGEXP = new RegExp('^[a-z0-9]+(\.[_a-z0-9]+)*@@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,50})$', 'i');
app.directive('cemail', function () {
return {
require: 'ngModel',
link: function (scope, elm, attrs, ctrl) {
ctrl.$parsers.unshift(function (viewValue) {
if (INTEGER_REGEXP.test(viewValue)) {
// it is valid
ctrl.$setValidity('cemail', true);
return viewValue;
} else {
// it is invalid, return undefined (no model update)
ctrl.$setValidity('cemail', false);
return undefined;
}
});
}
};
});
and in html
Required
Invalid Email