BUGFIX: Added single quote as a valid local-part of an email address as per RFC5322. Other symbols still excluded although in the spec

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@100825 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Mark Stephens 2010-03-10 23:45:40 +00:00 committed by Sam Minnee
parent 7b3255af5d
commit 1a9a01379b

View File

@ -16,7 +16,7 @@ Behaviour.register({
var el = _CURRENT_FORM.elements[fieldName];
if(!el || !el.value) return true;
if(el.value.match(/^([a-zA-Z0-9_+\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/)) {
if(el.value.match(/^([a-zA-Z0-9_+\-\.\x27]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/)) {
return true;
} else {
validationError(el, "$error","validation");
@ -42,7 +42,7 @@ JS;
function validate($validator){
$this->value = trim($this->value);
if($this->value && !ereg('^([a-zA-Z0-9_+\.\-]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$', $this->value)){
if($this->value && !ereg('^([a-zA-Z0-9_+\.\-\x27]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$', $this->value)){
$validator->validationError(
$this->name,
_t('EmailField.VALIDATION', "Please enter an email address."),