Using StringValidator to check if the character count is within range : StringValidator « Data Model « Flex






Using StringValidator to check if the character count is within range

Using StringValidator to check if the character count is within range
   

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:StringValidator source="{username}" 
                        property="text"
                        minLength="3" 
                        maxLength="20" 
                        trigger="{submitButton}"
                        triggerEvent="click"
                        tooShortError="at least 3 characters"
                        tooLongError="too long" />
    <mx:Text text="Enter your username:" />
    <mx:TextInput id="username" />
    <mx:Button label="Submit" id="submitButton" />
</mx:Application>

   
    
    
  








Related examples in the same category

1.Using ActionScript to validate min length text inputUsing ActionScript to validate min length text input
2.Change event we can validate in real timeChange event we can validate in real time
3.Set StringValidator to validate required fieldSet StringValidator to validate required field
4.Using the StringValidator classUsing the StringValidator class
5.A StringValidator ensures text has been entered.A StringValidator ensures text has been entered.
6.Too long error and too short error messages for StringValidatorToo long error and too short error messages for StringValidator
7.StringValidator for Form text inputStringValidator for Form text input
8.Validating required fieldsValidating required fields