Flex TextInput 动态推断输入内容

<?

xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
import spark.events.TextOperationEvent;
[Bindable]
private var errorStr:String = "";
protected function numInput_changeHandler(event:TextOperationEvent):void
{
var exp:RegExp= /[\d,,]/g; var inputText:String = numInput.text+'';
if(inputText==''){
return;
}
if(inputText.match(/[。,]$/)){
inputText = inputText.substring(0,inputText.length-1);
}
var temp:String = inputText.replace(exp,'');
var isRight:Boolean = true;
if(temp==''){
var arr:Array = inputText.split(/[,,]/);
for(var i:int =0;i<arr.length;i++){
var oneNum:String = arr[i];
if(oneNum==null || (oneNum+'')== ''){
isRight = false;
}
}
}else{
isRight = false;
}
if(isRight){
numInput.setStyle('borderColor','black');
alarmLabel.visible = false;
}else{
numInput.setStyle('borderColor','0xFF0000');
alarmLabel.visible = true;
}
}
]]>
</fx:Script>
<fx:Declarations>
</fx:Declarations>
<s:HGroup width="100%" height="30" horizontalAlign="left" paddingLeft="5"
paddingRight="5" verticalAlign="middle">
<s:Label width="60" text="号码:" textAlign="right"/>
<s:TextInput id="numInput" width="200" change="numInput_changeHandler(event)"
errorString="{errorStr}"/>
<s:Spacer width="16"/>
<s:Label id="alarmLabel" visible="false" color="0xFF0000" text="仅仅同意输入数字以“,”隔开"/>
</s:HGroup>
</s:Application>

最新文章

  1. [译]学习IPython进行交互式计算和数据可视化(四)
  2. Java笔试题(一)
  3. php : 匿名函数(闭包) [一]
  4. C++ 宽字符(wchar_t)与窄字符(char)的转换
  5. 微信45028错误,微信has no masssend quota hint错误
  6. 解决apache启动问题:httpd: Could not reliably determine the server&#39;s fully
  7. Eclipse、MyEclipse优化,提高运行速度
  8. cnpack热键
  9. C# Post和Get请求
  10. monkey简介与最常用命令
  11. codeforces round #419 C. Karen and Game
  12. numpy(二)
  13. mock数据,尽量随机,1次插入多条
  14. CSS 中的 !important 属性
  15. CSS3里的瀑布流效果
  16. MySQL分组查询,前3条数据
  17. C++ Primer 笔记——const 限定符
  18. php利用simple_html_dom类,获取页面内容,充当爬虫角色
  19. Node.js系列-express(下)
  20. jQuery中click事件多次触发解决方案

热门文章

  1. hdu1005 Number Sequence(寻找循环节)
  2. 【Hibernate步步为营】--双向关联一对一映射具体解释(一)
  3. Python3.4 邮件(包含附件与中国)
  4. URAL 1934 Black Spot --- 最短的简单修改
  5. Vijos P1881 闪烁的星星 (加强自己多一点。。)
  6. Windows 8 应用开发 - 应用栏
  7. 慎重使用MySQL auto_increment
  8. A WPF File ListView and ComboBox
  9. ProgressBar样式总结与自己主动填充方法(代码)
  10. Cocos发展Visual Studio下一个libcurl图书馆开发环境的搭建