Home Tutorial Flex Flex4 Components StringValidator in Flex4


Share on Google+Share on Google+
StringValidator in Flex4
Posted on: May 28, 2010 at 12:00 AM
The StringValidator class validates a string Which is in a specified range or not.

StringValidator in Flex4:

The StringValidator class validates a string Which is in a specified range or not.
You can set the minimuum and maximun range by using minLength and maxLength property.
The tag of StringValidator is <mxStringValidator>.


<?xml version="1.0" encoding="utf-8"?>

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"



minWidth="955" minHeight="600">



import mx.controls.Alert;




<fx:Model id="CheckString">





<mx:StringValidator source="{unametxt}" property="text"

tooShortError="The minimum length is 4 character. "

tooLongError="The maximum length is 15 character."

minLength="4" maxLength="15"

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

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


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

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

<mx:FormItem label="User Name: ">

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


<mx:FormItem >

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






Running Application:

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

Download this code


Related Tags for StringValidator in Flex4:

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: May 28, 2010

Recommend the tutorial

Advertisements Advertisements