积少成多Flash(12) - Flex 3.0 验证控件(Validator), 缓动效果(easing)
2009-11-28 00:00:00 来源:WEB开发网3、EmailValidator.mxml
<?xml version="1.0" encoding="utf-8"?>
<!--
应用 Email 验证控件的 Demo
-->
<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="400" height="300"
title="Validator - EmailValidator (Email验证)">
<mx:EmailValidator id="emailValidator" source="{txtEmail}" property="text"
missingAtSignError="缺少@"
valid="mx.controls.Alert.show('验证成功');"
/>
<mx:Form>
<mx:FormItem label="Email: ">
<mx:TextInput id="txtEmail"/>
</mx:FormItem>
<mx:FormItem >
<mx:Button id="btnSubmit" label="验证" click="emailValidator.validate();" />
</mx:FormItem>
</mx:Form>
</mx:Panel>
4、RegExpValidator.mxml
<?xml version="1.0" encoding="utf-8"?>
<!--
应用正则表达式验证控件的 Demo
-->
<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="400" height="300"
title="Validator - RegExpValidator (正则表达式验证)">
<mx:Script>
<![CDATA[
import mx.events.ValidationResultEvent;
import mx.validators.*;
import mx.controls.Alert;
private function handleResult(e:ValidationResultEvent):void
{
if (e.type == ValidationResultEvent.VALID)
{
Alert.show("验证成功");
}
}
]]>
</mx:Script>
<mx:RegExpValidator id="regExpValidator"
source="{txtInput}" property="text"
flags="g,i" expression="^[a-z]+$"
valid="handleResult(event)" invalid="handleResult(event)"
trigger="{btnSubmit}" triggerEvent="click"
noMatchError="请输入正确的英文字母"
required="false"
/>
<mx:Form>
<mx:FormItem label="请输入英文字母: ">
<mx:TextInput id="txtInput"/>
</mx:FormItem>
<mx:FormItem >
<mx:Button id="btnSubmit" label="验证" />
</mx:FormItem>
</mx:Form>
</mx:Panel>
- ››FLASH不等于运算符!=的使用实例
- ››FLASH不全等运算符!==
- ››FLASH字符串分隔符运算符
- ››FLASH% 模运算符
- ››Flash+、++、+= 加法运算符
- ››Flash, 逗号运算符
- ››flash中的-、--、-=减法运算符
- ››Flash的-Infinity 常数、.点运算符、/ 除法运算符...
- ››Flash两种注释方法/*..*/ 和// 注释行分隔符运算符...
- ››Flash的/=除法赋值运算符、=赋值运算符、== 等于运...
- ››Flash之?: 条件运算符、^ 按位 XOR 运算符、^= 按...
- ››Flash的_framesloaded代码示例
更多精彩
赞助商链接