您的位置:首页 > 其它

验证IP是否合法

2010-11-18 15:49 211 查看
package check
{
import mx.events.ValidationResultEvent;
import mx.validators.RegExpValidator;

public class Check
{
var regExpValidator:RegExpValidator=new RegExpValidator;

public function is_Ip(ip:Object):Boolean{
var result:Boolean=true;
this.regExpValidator.property="text";
this.regExpValidator.source=ip;
this.regExpValidator.expression="^(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]{1}|0[1-9]{1}[0-9]{1}|00[1-9]{1})\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]{1}|0[1-9]{1}[0-9]{1}|00[1-9]{1}|0)\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]{1}|0[1-9]{1}[0-9]{1}|00[1-9]{1}|0)\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]{1}|0[1-9]{1}[0-9]{1}|00[1-9]{1}|0)$";
this.regExpValidator.noMatchError="格式错误";

var event:ValidationResultEvent=this.regExpValidator.validate();
if(event.type==ValidationResultEvent.INVALID){
result=false;
}
return result;
}

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