diff options
author | Patrick Maia <patrickjourdanmaia@gmail.com> | 2014-12-08 20:56:52 +0000 |
---|---|---|
committer | Patrick Maia <patrickjourdanmaia@gmail.com> | 2014-12-09 00:45:03 +0000 |
commit | b636c1d8c3c4fe86f08a141d6009603163597059 (patch) | |
tree | 06bb2c331102be8eeea6ff0d4a9d7bab203bae74 /web-ui/app/js | |
parent | a67a232fd026069de44e701278d2750c3440e677 (diff) |
Card #168 - does not accept obviously invalid email addresses
Diffstat (limited to 'web-ui/app/js')
-rw-r--r-- | web-ui/app/js/mail_view/ui/recipients/recipients_input.js | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/web-ui/app/js/mail_view/ui/recipients/recipients_input.js b/web-ui/app/js/mail_view/ui/recipients/recipients_input.js index c1c32d77..ef860eb0 100644 --- a/web-ui/app/js/mail_view/ui/recipients/recipients_input.js +++ b/web-ui/app/js/mail_view/ui/recipients/recipients_input.js @@ -111,13 +111,18 @@ define([ var value = (data && data.value) || this.$node.val(); var that = this; _.each(value.split(/[,;]/), function(address) { - if (!_.isEmpty(address.trim())) { + if(that.isValidEmailAddress(address.trim())) { that.trigger(that.$node, events.ui.recipients.entered, { name: that.attr.name, address: address.trim() }); } }); reset(this.$node); }; + this.isValidEmailAddress = function(address) { + // valid emails are in the format: 'user@domain.smt' or 'User <user@domain.smt>' + return /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}|[A-Z ]+<[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}>$/i.test(address); + }; + this.init = function () { this.$node.typeahead({ hint: true, |