Flex: 输入组件 – TextInput, ComboBox, Radiobutton, TextArea等 对其输入内容进行验证

Categories: 垃圾山; Tagged with: ; @ February 20th, 2009 14:01

如: 某编辑器:

image

代码:

textName.addEventListener(Event.CHANGE, onTextNameChange);//增加监听函数,监听EventChange, 如果不需实时验证, 可监听FlexEvent.VALUE_COMMIT事件.
	 //------------------Validation - Name -  on Event.Change------------
	 private function onTextNameChange(e:Event = null):void {
		if(StringUtils.trim(textName.text).length < 2) {
			textName.errorString = "Name不能少于2个字符, 请重新输入";
		}else if(StringUtils.trim(textName.text) == "String") {
			textName.errorString = "Name不可为'String'";
		}else {
			textName.errorString = null;
		}
		setButton();
	 }

<->



// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.