Last active
August 29, 2015 14:17
-
-
Save zerobatu/d1f1a91f63857f84474f to your computer and use it in GitHub Desktop.
revisa lista de mail de un texto
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // limpia los espacios | |
| var emailTrim = function(e) { return e.trim(); } | |
| // filtra los textos en blanco | |
| var filterMails = function(e) { return e.trim() !== "" } | |
| // retorna los mail invalidos | |
| var validMail = function(e) { | |
| var re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; | |
| return !e.match(re); | |
| } | |
| sending = function(emails) { | |
| // si no encuentra ningun mail invalido envia el mail | |
| if(emails.split(/,|;/).map(emailTrim).filter(filterMails).filter(validMail).length) { | |
| // error | |
| } else { | |
| // envia los mail | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment