Flex TextInput 动态推断输入内容
2024-08-29 06:19:36
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>
最新文章
- [译]学习IPython进行交互式计算和数据可视化(四)
- Java笔试题(一)
- php : 匿名函数(闭包) [一]
- C++ 宽字符(wchar_t)与窄字符(char)的转换
- 微信45028错误,微信has no masssend quota hint错误
- 解决apache启动问题:httpd: Could not reliably determine the server&#39;s fully
- Eclipse、MyEclipse优化,提高运行速度
- cnpack热键
- C# Post和Get请求
- monkey简介与最常用命令
- codeforces round #419 C. Karen and Game
- numpy(二)
- mock数据,尽量随机,1次插入多条
- CSS 中的 !important 属性
- CSS3里的瀑布流效果
- MySQL分组查询,前3条数据
- C++ Primer 笔记——const 限定符
- php利用simple_html_dom类,获取页面内容,充当爬虫角色
- Node.js系列-express(下)
- jQuery中click事件多次触发解决方案
热门文章
- hdu1005 Number Sequence(寻找循环节)
- 【Hibernate步步为营】--双向关联一对一映射具体解释(一)
- Python3.4 邮件(包含附件与中国)
- URAL 1934 	Black Spot --- 最短的简单修改
- Vijos P1881 闪烁的星星 (加强自己多一点。。)
- Windows 8 应用开发 - 应用栏
- 慎重使用MySQL auto_increment
- A WPF File ListView and ComboBox
- ProgressBar样式总结与自己主动填充方法(代码)
- Cocos发展Visual Studio下一个libcurl图书馆开发环境的搭建