WEB开发网
开发学院图形图像Flash 积少成多Flash(12) - Flex 3.0 验证控件(Validato... 阅读

积少成多Flash(12) - Flex 3.0 验证控件(Validator), 缓动效果(easing)

 2009-11-28 00:00:00 来源:WEB开发网   
核心提示: 3、EmailValidator.mxml<?xmlversion="1.0"encoding="utf-8"?><!--应用Email验证控件的Demo--><mx:Panelxmlns:mx="http://ww

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>

上一页  1 2 3 4 5 6  下一页

Tags:积少成多 Flash Flex

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接