Created
August 19, 2014 09:42
-
-
Save leonlihkust/f4236b3986669095fc85 to your computer and use it in GitHub Desktop.
Add restriction to text box InDesign
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var textRestrict:spark.components.TextInput; | |
textRestrict.restrict = "0-9," //Numbers and comma only | |
/********************************************************* | |
textRestrict.maxChars = 5; | |
textRestrict.restrict = "a-zA-Z0-9"; //Alpha-numeric only | |
textRestrict.restrict = "0-9"; //Numbers only | |
textRestrict.restrict = "^a-z"; //All chars, only uppercase alpha | |
textRestrict.restrict = "\u0020-\u007E"; //ASCII chars 32 (space) through 126 (tilde) only | |
textRestrict.restrict = "^\^\-"; //All chars but not the caret or hyphen | |
*********************************************************/ | |
textRestrict.addEventListener(TextOperationEvent.CHANGE,onTextChanged); | |
public function onTextChanged(e:TextOperationEvent):void | |
{ | |
var inputTxt:spark.components.TextInput = e.target as spark.components.TextInput; | |
var reg:RegExp = /[^,]*,[^,]*,/g; | |
if(inputTxt.text.search(reg) != -1) | |
inputTxt.text = inputTxt.text.substr(0,inputTxt.text.length-1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment