ZipCodeValidator in Flex4


 

ZipCodeValidator in Flex4

The ZipCodeValidator class validates the correct length of the numeric value.

The ZipCodeValidator class validates the correct length of the numeric value.

ZipCodeValidator in Flex4:

The ZipCodeValidator class validates the correct length of the numeric value.
It checks the length for a five-digit ZIP code, a five-digit+four-digit United States ZIP code.
The tag of ZipCodeValidator is <mx:ZipCodeValidator>.

Example:

<?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">

<fx:Script>

<![CDATA[

import mx.controls.Alert;

]]>

</fx:Script>

<fx:Declarations>

<fx:Model id="CheckZipCode">

<zipcodeInfo>

<Zipcode>{ziptxt.text}</Zipcode>

</zipcodeInfo>

</fx:Model>

<mx:ZipCodeValidator source="{ziptxt}" property="text"

trigger="{btn}" triggerEvent="click"

valid="Alert.show('Validation Succeeded!');"/>

</fx:Declarations>

<s:Panel title="ZipCodeValidator Example" width="550">

<mx:Form height="94" width="548" backgroundColor="#101446" color="#FFFFFF">

<mx:FormItem label="Enter a Zip code: ">

<s:TextInput id="ziptxt" width="100%" color="#000000"/>

</mx:FormItem>

<mx:FormItem >

<s:Button id="btn" label="Check Validation" chromeColor="#5F1B0C"/>

</mx:FormItem>

</mx:Form>

0

</s:Panel>

</s:Application>

Output:

1

Running Application:

To view this page ensure that Adobe Flash Player version 10.0.0 or greater is installed.

Download this code

2

Ads