加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Flex restrict 输入限制

发布时间:2020-12-15 01:24:11 所属栏目:百科 来源:网络整理
导读:Flex 中TextInput和TextArea有一个比较有用的属性restrict(约束,限定),看下面例子: 1,mx:extInput id="test_ti" width="160" maxChars="20" restrict="0-9" text="0"/ 这样,这个输入框最多只能输入20个字符,只能输入0到9之间的数字了,你如果输入别的是输入
Flex中TextInput和TextArea有一个比较有用的属性restrict(约束,限定),看下面例子: 1,<mx:extInput id="test_ti" width="160" maxChars="20" restrict="0-9" text="0"/> 这样,这个输入框最多只能输入20个字符,只能输入0到9之间的数字了,你如果输入别的是输入不进去的 2,<mx:extInput id="test_ti" width="160" maxChars="20" restrict="0-9." text="0"/> 这样,输入框可以输入0到9之间的数字,以及输入'.',中间必须用''分隔开来 3,<mx:extInput id="test_ti" width="160" restrict="0-9ab" text="0"/>这样,以及a,或b 4,<mx:extInput id="test_ti" width="160" restrict="a-z" text="0"/> 可以输入a到z之间任何一个英文字母,'-'表示区间,如果要输入'-',就必须加'',如- 结论: 用restrict有个好处,就是省去了验证的麻烦,比如检验是否为数字,如果加了restrict="0-9",就不需要检验了,因为这个输入框只能输入0到9之间的数字,别的输不进去 <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:x="http://ns.adobe.com/mxml/2009" ? ? ? xmlns:s="library://ns.adobe.com/flex/spark" ? ? ? xmlns:mx="library://ns.adobe.com/flex/halo" minWidth="1024" minHeight="768" backgroundColor="#A7E460"> <s:layout> ? <s:BasicLayout/> </s:layout> <fx:eclarations> ? <!-- Place non-visual elements (e.g.,services,value objects) here --> </fx:eclarations> <s:extInput x="167" y="190" restrict="0-9"/> <s:abel x="70" y="190" text="只能输入数字" width="89" height="22" /> <s:abel x="70" y="234" text="只能输入字母" width="89" height="23"/> <s:TextInput x="167" y="234" restrict="A-Z"/> </s:Application>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读