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