Fixes #121: Replaced the 'validateEmail' validation with a RFC822 regex expression.

This commit is contained in:
Alex Tselegidis 2016-02-15 22:19:04 +01:00
parent e243a7b16c
commit df0d81f68c

View file

@ -187,13 +187,13 @@ var GeneralFunctions = {
* This method validates an email address. If the address is not on the proper * This method validates an email address. If the address is not on the proper
* form then the result is FALSE. * form then the result is FALSE.
* *
* @link http://stackoverflow.com/a/46181 * @link http://badsyntax.co/post/javascript-email-validation-rfc822
* *
* @param {string} email The email address to be checked. * @param {string} email The email address to be checked.
* @returns {bool} Returns the validation result. * @returns {bool} Returns the validation result.
*/ */
validateEmail: function (email) { validateEmail: function (email) {
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,}))$/; var re = /^([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22))*\x40([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d))*$/;
return re.test(email); return re.test(email);
}, },