<?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="600" minHeight="400">
<fx:Declarations>
<mx:StringValidator tooShortError="长度必须大于等于6" tooLongError="长度必须小于等于20" id="usernamevalidate" minLength="6" maxLength="20" trigger="{submit}" triggerEvent="click" source="{userid}" property="text">
</mx:StringValidator>
<mx:StringValidator id="userpwdvalidate" minLength="6" maxLength="20" trigger="{submit}" triggerEvent="click" source="{userpwd}" property="text">
</mx:StringValidator>
<mx:EmailValidator id="emailvalidate" trigger="{submit}" triggerEvent="click" source="{useremail}" property="text">
</mx:EmailValidator>
<mx:PhoneNumberValidator id="phonevalidate" trigger="{submit}" triggerEvent="click" source="{phone}" property="text">
</mx:PhoneNumberValidator>
<mx:DateValidator id="birthvalidate" trigger="{submit}" triggerEvent="click" source="{birthday}" property="text">
</mx:DateValidator>
</fx:Declarations>
<fx:Script>
<![CDATA[
import flash.events.MouseEvent;
import mx.controls.Alert;
import mx.validators.Validator;
protected function submit_clickHandler(event:MouseEvent):void
{
var val:Array=Validator.validateAll([usernamevalidate,userpwdvalidate,emailvalidate,phonevalidate,birthvalidate]);
if(val.length!=0){
Alert.show("请完善相关资料","信息");
return;
}
Alert.show("注册成功....");
}
protected function reset_clickHandler(event:MouseEvent):void
{
this.userid.text=null;
this.userpwd.text=null;
this.useremail.text=null;
this.phone.text=null;
this.birthday.text=null;
}
]]>
</fx:Script>
<s:Panel x="152" y="41" width="353" height="297" title="用户注册信息">
<s:layout>
<s:VerticalLayout />
</s:layout>
<mx:Form>
<mx:FormItem label="用户名:" required="true">
<s:TextInput id="userid"/>
</mx:FormItem>
<mx:FormItem label=" 密 码:" required="true">
<s:TextInput id="userpwd"/>
</mx:FormItem>
<mx:FormItem label=" 邮 箱:" required="true">
<s:TextInput id="useremail"/>
</mx:FormItem>
<mx:FormItem label=" 电 话:">
<s:TextInput id="phone"/>
</mx:FormItem>
<mx:FormItem label="出生年月:">
<s:TextInput id="birthday"/>
</mx:FormItem>
</mx:Form>
<s:Group>
<s:layout>
<s:HorizontalLayout paddingLeft="150"/>
</s:layout>
<s:Button label="提交" id="submit" click="submit_clickHandler(event)" />
<s:Button label="重置" id="reset" click="reset_clickHandler(event)"/>
</s:Group>
</s:Panel>
</s:Application>
flex注册页面
最新推荐文章于 2018-06-01 18:09:25 发布