Update email regex to allow:

Nathan Gray <ng.dot@email.com>
This commit is contained in:
Nathan Gray 2013-10-11 14:35:13 +00:00
parent 536a939e6c
commit f73f8fea89
2 changed files with 8 additions and 4 deletions

View File

@ -21,7 +21,7 @@ class etemplate_widget_url extends etemplate_widget
/** /**
* Regexes for validating * Regexes for validating
*/ */
const EMAIL_PREG = '^[^\x00-\x20()<>@,;:\\".\[\]]+@([a-z0-9ÄÖÜäöüß](|[a-z0-9ÄÖÜäöüß_-]*[a-z0-9ÄÖÜäöüß])\.)+[a-z]{2,6}'; const EMAIL_PREG = '^(?:[ a-z0-9!#$%&\'*+\/=?^_`{|}\(\)~-]+<)?[^\x00-\x20()<>@,;:\"\[\]]+@([a-z0-9ÄÖÜäöüß](|[a-z0-9ÄÖÜäöüß_-]*[a-z0-9ÄÖÜäöüß])\.)+[a-z]{2,6}';
/** /**
* Validate input * Validate input

View File

@ -32,7 +32,7 @@ var et2_url = et2_textbox.extend(
}, },
// PREG for client-side validation copied from etemplate_widget_url // PREG for client-side validation copied from etemplate_widget_url
EMAIL_PREG: new RegExp(/^[^\x00-\x20()<>@,;:\".\[\]]+@([a-z0-9ÄÖÜäöüß](|[a-z0-9ÄÖÜäöüß_-]*[a-z0-9ÄÖÜäöüß])\.)+[a-z]{2,6}/), EMAIL_PREG: new RegExp(/^(?:[ a-z0-9!#$%&'*+/=?^_`{|}\(\)~-]+<)?[^\x00-\x20()<>@,;:\"\[\]]+@([a-z0-9ÄÖÜäöüß](|[a-z0-9ÄÖÜäöüß_-]*[a-z0-9ÄÖÜäöüß])\.)+[a-z]{2,6}/i),
/** /**
* @memberOf et2_url * @memberOf et2_url
*/ */
@ -198,7 +198,11 @@ var et2_url = et2_textbox.extend(
} }
break; break;
case "url-email": case "url-email":
if(!e.data.EMAIL_PREG.test(value)) if(!e.data.EMAIL_PREG.test(value) ||
// If they use Text <email>, make sure the <> match
(value.indexOf("<") > 0 && value.indexOf(">") != value.length-1) ||
(value.indexOf(">") > 0 && value.indexOf("<") < 0)
)
{ {
e.data.showMessage("Invalid email","validation_error",true); e.data.showMessage("Invalid email","validation_error",true);
} }