fixed EmailValidator IDN and full pattern support

also made everything conistent with client validation
This commit is contained in:
Carsten Brandt
2013-11-20 16:17:23 +01:00
parent 64862f96ca
commit 8dab87be3d
3 changed files with 56 additions and 7 deletions

View File

@@ -117,16 +117,16 @@ yii.validation = (function ($) {
var valid = true;
if (options.enableIDN) {
var regexp = /^(.*)@(.*)$/,
var regexp = /^(.*<?)(.*)@(.*)(>?)$/,
matches = regexp.exec(value);
if (matches === null) {
valid = false;
} else {
value = punycode.toASCII(matches[1]) + '@' + punycode.toASCII(matches[2]);
value = matches[1] + punycode.toASCII(matches[2]) + '@' + punycode.toASCII(matches[3]) + matches[4];
}
}
if (!valid || !(value.match(options.pattern) && (!options.allowName || value.match(options.fullPattern)))) {
if (!valid || !(value.match(options.pattern) || (options.allowName && value.match(options.fullPattern)))) {
addMessage(messages, options.message, value);
}
},