只能输入数字.
示例:
代码:
<?
xml version="1.0" encoding="utf-8"
?>
<!-- http://blog.flexexamples.com/2008/05/15/restricting-which-characters-a-user-can-type-in-a-textinput-control-in-flex/ -->
< 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 ="0-9-"
change ="textInput_change(event);" />
</ mx:ApplicationControlBar >
< mx:DataGrid id ="dataGrid"
dataProvider =" {arrColl} "
width ="100%"
height ="100%" />
</ mx:Application >
<!-- http://blog.flexexamples.com/2008/05/15/restricting-which-characters-a-user-can-type-in-a-textinput-control-in-flex/ -->
< 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 ="0-9-"
change ="textInput_change(event);" />
</ mx:ApplicationControlBar >
< mx:DataGrid id ="dataGrid"
dataProvider =" {arrColl} "
width ="100%"
height ="100%" />
</ mx:Application >
来自: http://blog.flexexamples.com/2008/05/15/restricting-which-characters-a-user-can-type-in-a-textinput-control-in-flex/