时间:2021-05-28
复制代码 代码如下:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
creationComplete="initHandler(event)">
<fx:Script>
<![CDATA[
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;
}
]]>
</fx:Script>
<fx:Declarations>
<mx:StringValidator id="NAMEValidator"
source="{username}"
property="text"
minLength="6" maxLength="16"
tooLongError="不能多于16个字符" tooShortError="不能低于六位"
required="true"
invalid="NAMEValidator_invalidHandler(event)"
/>
<mx:NumberValidator id="AGEValidator" source="{age}"
domain="int" allowNegative="false" maxValue="60" minValue="18"
required="true" property="text"
exceedsMaxError="不能大于60" lowerThanMinError="不能低于十八"
invalid="AGEValidator_invalidHandler(event)"
/>
<mx:PhoneNumberValidator id="PHONEValidator"
minDigits="11" property="text"
source="{phone}"
required="true"
invalid="PHONEValidator_invalidHandler(event)"/>
</fx:Declarations>
<mx:Panel>
<mx:Form>
<mx:FormItem label="name">
<mx:TextInput id="username"/>
</mx:FormItem>
<mx:FormItem label="age">
<mx:TextInput id="age"/>
</mx:FormItem>
<mx:FormItem label="phone">
<mx:TextInput id="phone"/>
</mx:FormItem>
<mx:FormItem>
<mx:Button label="验证" id="btn" click="btn_clickHandler(event)"/>
</mx:FormItem>
</mx:Form>
</mx:Panel>
</s:Application>
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
案例基础布局htmlcss.box{display:-webkit-flex;display:flex;}.item{width:200px;height:30
css实现流程导航效果,具体内容如下所示:::tip使用纯css线上流程导航效果。本文统一采取flex布局,你也可以采用其他布局实现,核心原理不变:::##方法
本文主要介绍了如何实现小程序tab栏下划线动画效果,分享给大家,具体如下:最终效果实现wxml{{item}}wxss.abox{display:flex;fl
filter(function,sequence):对sequence中的item依次执行function(item),将执行结果为True的item组成一个L
设计风格简约统一。设计风格不统一会产生界面混乱的结果,且会降低用户找寻信息的速度,而风格简约则是降低信息堆积的最有效手段,只有简约化且统一的界面编排,才能促进信