ZipCodeValidator 验证邮政编码

来源:互联网 发布:mac唇膏火鹤好看吗 编辑:程序博客网 时间:2024/04/27 17:27

 <?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:s="library://ns.adobe.com/flex/spark"
        xmlns:mx="library://ns.adobe.com/flex/mx"
        width="514" height="387">
 <fx:Script>
  <![CDATA[
   import mx.controls.Alert;
  ]]>
 </fx:Script>
 <fx:Declarations>
  <mx:ZipCodeValidator source="{zip}"
        property="text"           
        wrongUSFormatError="出现无效字符"      
        wrongLengthError="请输入5位或者9位数字"    
        wrongCAFormatError="请输入5位或者9位数字" 
        trigger="{myButton}"
        triggerEvent="click" 
        valid="Alert.show('输入正确!');"/>
 </fx:Declarations>
 
 <s:Panel left="30" right="30" height="198" borderAlpha="0.15" chromeColor="#3D75F6" title="验证数字"
    verticalCenter="-5">
  <mx:Form color="0x323232" horizontalCenter="0" verticalCenter="0">
   <mx:FormItem width="232" label="输入邮编: " fontSize="12" fontWeight="normal">
    <s:TextInput id="zip" width="158"/>
   </mx:FormItem>
   
   <mx:FormItem >
    <s:Button id="myButton" label="确定" chromeColor="#A5AAB5"/>
   </mx:FormItem>
  </mx:Form>
 </s:Panel>                                          
</s:WindowedApplication>

原创粉丝点击