Skip to content
Snippets Groups Projects
Commit e57e46ae authored by Benoit Lavenier's avatar Benoit Lavenier
Browse files

[enh] Add new directive for email validation

parent 45b85b8f
No related branches found
No related tags found
No related merge requests found
...@@ -47,6 +47,20 @@ angular.module('cesium') ...@@ -47,6 +47,20 @@ angular.module('cesium')
}; };
}) })
.directive('email', function() {
var EMAIL_REGEXP = new RegExp('^[a-z0-9!#$%&\'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$');
return {
require: 'ngModel',
link: function(scope, element, attrs, ngModel) {
if (ngModel) {
ngModel.$validators.email = function (value) {
return ngModel.$isEmpty(value) || EMAIL_REGEXP.test(value);
};
}
}
};
})
// Add a copy-on-click directive // Add a copy-on-click directive
.directive('copyOnClick', function ($window, $document, Device, UIUtils) { .directive('copyOnClick', function ($window, $document, Device, UIUtils) {
'ngInject'; 'ngInject';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment