Search code examples
actionscript-3apache-flexflash-builderflexbuilder

Validating alphabets only stored in a string in flex


I am trying to validate if only alphabets are typed in a text box. The code i am using is

<mx:StringValidator id="loginValidator"     source="{loginTextField}" property="text" required="true" minLength="2" />


validatorErrorArray = Validator.validateAll([loginValidator, ...])

Now the problem is, it also validates characters like */- and ;',./ etc i want to validate only numbers and or alphabets. If anyone can point out mistake and changes that should be made

Best Regards


Solution

  • If you want Only Alphabets and numbers to accepted you can use restrict property.

    <s:TextInput restrict="0-9a-zA-Z"/>
    

    This will allow only numbers and alphabets.