您的位置:首页 > 其它

flex 验证邮件正则表达式 匹配多个收件人

2010-09-02 14:25 330 查看
package eserver.dbaudit.renderers.validators

{

import com.captech.utils.GetText;

import eserver.common.utils.StringUtil;

import mx.validators.StringValidator;

import mx.validators.ValidationResult;

public class MutiEmailValidator extends StringValidator

{

private var results:Array;

public function MutiEmailValidator()

{

super();

}

override protected function doValidation(value:Object):Array {

var txt:String = value as String;

results = [];

results = super.doValidation(value);

if (results.length > 0) {

return results;

}

txt = txt.replace(',', ';');

var tempArry:Array = StringUtil.toArray(txt, ';');

var len:int = tempArry.length;

// var reg:RegExp = /(/w+((-/w+)|(/./w+))*)/+/w+((-/w+)|(/./w+))*/@[A-Za-z0-9]+((/.|-)[A-Za-z0-9]+)*/.[A-Za-z0-9]+/;

// var reg:RegExp = /([a-z0-9A-Z]+[-|/.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?/.)+[a-zA-Z]{2,}/;

var reg:RegExp = /^([a-z0-9A-Z]+[_/.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?/.)+[a-zA-Z]{2,}$/;

while (len--) {

if (!reg.test(tempArry[len])) {

results.push(new ValidationResult(true,

"text",

"StringTooLong",

GetText._('[{0}] does not match the format',

tempArry[len])));

}

}

return results;

}

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: