加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Flex StringValidator验证例子

发布时间:2020-12-15 03:52:03 所属栏目:百科 来源:网络整理
导读:http://blog.sina.com.cn/s/articlelist_1829618345_3_2.html 把提交绑定到按钮上面了,去掉了trigger 和triggerEvent这样,提交不合格信息不需要移动到输入就可以出现红色提示框 ?xml version="1.0"encoding="utf-8"? mx:Applicationxmlns:mx="http://www.a
http://blog.sina.com.cn/s/articlelist_1829618345_3_2.html

把提交绑定到按钮上面了,去掉了trigger 和triggerEvent这样,提交不合格信息不需要移动到输入就可以出现红色提示框

Flex?<wbr>StringValidator验证例子2



<?xml version="1.0"encoding="utf-8"?>
<mx:Applicationxmlns:mx="http://www.adobe.com/2006/mxml"layout="vertical">
<mx:Style>
? ? Application{fontSize:12px;}
? ? ? .errorTip{fontSize:12px;}
</mx:Style>
<mx:Script>
? ? ? <![CDATA[
? ? ? ? ? ? importmx.events.ValidationResultEvent;
? ? ? ? ? ? import mx.controls.Alert;
? ? ? ? ? ? private functioncheck():void{
? ? ? ? ? ? ? ? ? var re:ValidationResultEvent =tiValid.validate();
? ? ? ? ? ? ? ? ? if(re.results != null){
? ? ? ? ? ? ? ? ? ? ? ? tiValid.source.dispatchEvent(
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? newMouseEvent(MouseEvent.MOUSE_OVER)
? ? ? ? ? ? ? ? ? ? ? ? );
? ? ? ? ? ? ? ? ? }else{
? ? ? ? ? ? ? ? ? ? ? ? Alert.show('ok');
? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ]]>
</mx:Script>
? ? ? <mx:StringValidatorid="tiValid" source="{txt}"?
property="text" required="true" maxLength="10"minLength="6"?
requiredFieldError="不能为空" tooLongError="不超过10个字符"tooShortError="不少于6个字符" />
? ? ? <mx:PanelpaddingTop="20" paddingRight="20" paddingBottom="20"paddingLeft="20">
? ? ? ? ? ? <mx:TextInputid="txt" width="200" />
? ? ? ? ? ? <mx:Buttonid="btn" label="提交" click="check()" />
? ? ? </mx:Panel>
</mx:Application>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读