Limiting characters for input text

hello everyone,
can’t quite seem to figure this out…
i have this quiz i’m making and it contains 4 input text boxes. there will be 3 options: a,b, or c. and now my question:

how can i make the input boxes only accept the keys a,b,and c?
(currently you can type in any character)

hoping there is an easy answer,
-sogajunk

Hey soga,
Give your text field an instance name such as ‘tb’. In your timeline, add the following action:[AS]tb.restrict = “a-c”;[/AS]

That should work. Also, in the Text Properties panel, set the maximum characters to 1. That will prevent people from entering aaa or aab or cab or any other goofy combinations people have a tendency to use :wink:

Cheers!
Kirupa :smirk:

:azn:
fantastic!!! thanks so much Kirupa!

no problem :ub:

For future reference you can use maxChars to set the maximum amount of characters a user can input…

[AS]tb.maxChars = 1;[/AS]

It comes in handy when using createTextField() in Flash :slight_smile:

[edit]

And you can let the user use both lowercase and uppercase letters by defining that in the restrict property.

[AS]tb.restrict = “a-cA-C”;[/AS]

thanks beta! (hope it’s ok that i call you beta:thumb: )

No problem soga. And yes, it is alright that you call me beta, many do :slight_smile: