flex中validateall()方法实现多Item验证且结果统一提示(flex布局居中)干货满满

随心笔谈2年前发布 编辑
172 0
🌐 经济型:买域名、轻量云服务器、用途:游戏 网站等 《腾讯云》特点:特价机便宜 适合初学者用 点我优惠购买
🚀 拓展型:买域名、轻量云服务器、用途:游戏 网站等 《阿里云》特点:中档服务器便宜 域名备案事多 点我优惠购买
🛡️ 稳定型:买域名、轻量云服务器、用途:游戏 网站等 《西部数码》 特点:比上两家略贵但是稳定性超好事也少 点我优惠购买

xmlns:s=”library://ns.adobe.com/flex/spark”

xmlns:mx=”library://ns.adobe.com/flex/mx” minWidth=”955″ minHeight=”600″

creationComplete=”initHandler(event)”>

import mx.controls.Alert;

import mx.events.FlexEvent;

import mx.events.ValidationResultEvent;

import mx.validators.Validator;

private var error1:String;

private var error2:String;

private var error3:String;

protected function initHandler(event:FlexEvent):void

{

}

protected function btn_clickHandler(event:MouseEvent):void

{

// TODO Auto-generated method stub

var validateArray:Array=Validator.validateAll(

[NAMEValidator,AGEValidator,PHONEValidator]);

if(validateArray.length==0)

{

Alert.show(“成功啦!”);

}else

{

Alert.show(error1+”\n”+error2+”\n”+error3);

}

}

protected function NAMEValidator_invalidHandler(event:ValidationResultEvent):void

{

error1=event.message;

}

protected function AGEValidator_invalidHandler(event:ValidationResultEvent):void

{

error2=event.message;

}

protected function PHONEValidator_invalidHandler(event:ValidationResultEvent):void

{

error3=event.message;

}

]]>

source=”{username}”

property=”text”

minLength=”6″ maxLength=”16″

tooLongError=”不能多于16个字符” tooShortError=”不能低于六位”

required=”true”

invalid=”NAMEValidator_invalidHandler(event)”

/>

domain=”int” allowNegative=”false” maxValue=”60″ minValue=”18″

required=”true” property=”text”

exceedsMaxError=”不能大于60″ lowerThanMinError=”不能低于十八”

invalid=”AGEValidator_invalidHandler(event)”

/>

minDigits=”11″ property=”text”

source=”{phone}”

required=”true”

invalid=”PHONEValidator_invalidHandler(event)”/>

© 版权声明

相关文章