`

Flex-TextInput控件restrict属性

    博客分类:
  • Flex
阅读更多
Flex中如何通过设置restrict属性,在TextInput控件中限制用户可以输入的字符串
Flex中如何通过设置restrict属性,在TextInput控件中限制用户可以输入的字符串。本例中在restrict属性中设置了“a-z\0-9\-”,也就是只允许用户输入0到9的数字a到z的字母以及间隔符(-)。

 

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">
 
    <mx:Script>
        <![CDATA[
            private function textInput_change(evt:Event):void {
                arrColl.addItem(evt);
            }
        ]]>
    </mx:Script>
 
    <mx:ArrayCollection id="arrColl" />
 
    <mx:ApplicationControlBar dock="true">
        <mx:TextInput id="textInput"
                restrict="a-z\0-9\-"
                change="textInput_change(event);" />
    </mx:ApplicationControlBar>
 
    <mx:DataGrid id="dataGrid"
            dataProvider="{arrColl}"
            width="100%"
            height="100%" />
 
</mx:Application>

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics