开发者

Text Input restrict in Flex3 Air

I need to restrict the user and allow only first character as + or - or 0-9 and other ch开发者_如何学Goaracter as 0-9..how can i do this

in regular expression validator the below expression works but i need in restrict field.

<mx:TextInput id="txtTop"  restrict="[0-9+-][0-9]*$" />

Valid values are

+023

-123

23

0

invalid

+-123

fsaf

-+2132

Thanks in advance


Change the value of restrict based on the length of the string.

<mx:TextInput id="ti" restrict="[0-9+\-]" change="onChange(event)"/>

private function onChange(event:Event):void
{
    if(ti.text.length > 0)
        ti.restrict = "[0-9]";
    else
        ti.restrict = "[0-9+\-]"
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜