Restricting input to certain chars eg numbers

Make a mc with a dynamic text in it. Name the textvariable "text". Place the mc on the timeline and attach the following script to it: (To restrict to other chars, simply change the string allowed) onClipEvent(load){ //init the textfield text = ""; //this are the allowed characters allowed="0123456789"; } onClipEvent(keyUp){ var ch; //get the pressed key as character ch = chr(Key.getCode()); //check if this character is in allowed if(allowed.indexOf(ch) != -1){ //the character is ok, append it to our string text += ch; } }
bokel Date: 12/10/2001

if you use embedded fonts, you can restrict the input-chars by including only the corresponding outlines. thanks to urami for that tip
leo Date: 03/11/2001

what a great site
Rohit Date: 12/08/2002
The embedding option will work only if you have one textbox. If you have multiple textboxes in the form then this won't work
Da Hammer Date: 05/12/2004
You can do multiple textboxes as long as the each limited textbox share the same fontfamily with the same restrictions.
Add comment
Home