Flex中限制TextInput输入??
2012-05-20 18:51:20|??分类: 默认分类 |??标签:flex??输入字符?? |举报 |字号?订阅
1. 限制某个字符的输入,用符号 ^ 跟上要限制的字符,可跟多个字符?
????? <!-- 限制字符"~"的输入 -->?
???? <mx:TextInput id="xxx"? restrict="^~" />?
???? <!-- 限制字符"ab"的输入 -->?
???? <mx:TextInput id="xxx"? restrict="^ab" />?
2. 设置只能输入某些字符,将允许输入的字符罗列出来即可,也可以用 - 组合表示字符范围?
????? <!-- 只能输入abc -->?
???? <mx:TextInput id="xxx"? restrict="abc" />?
???? <!-- 只能输入小写字母 -->?
???? <mx:TextInput id="xxx"? restrict="a-z" />?
???? <!-- 只能输入小写字母、大写字母和数字 -->?
???? <mx:TextInput id="xxx"? restrict="a-zA-Z0-9" />?
3. 组合使用?
????? <!-- 只能输入数字和符号"." -->?
???? <mx:TextInput id="xxx"? restrict="0-9." />?
???? <!-- 只能输入除ab之外的小写字母 -->?
???? <mx:TextInput id="xxx"? restrict="a-z^ab" />
4.其他
???? 只允许输入数字和负号:<s:TextInput id="textinput_LOGOLeftW" restrict="0-9-+" />
????? 只允许输入数字和点号:<mx:TextInput id="txt" restrict="0-9." />
????? 只允许输入数字、英文、汉字:<mx:TextInput restrict="0-9a-z^{'[u4e00-u9fa5]'}"?/>
限制输入长度: maxChars=""