天天看点

flex验证之validator

validator有两个四个重要属性:

source:表示的id的源

property:表示源的属性

required:表示是不是必填项

requiredFieldError:不填时的提示信息

<?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">
	<s:layout>
		<s:BasicLayout/>
	</s:layout>
	<fx:Declarations>
		<!-- 将非可视元素(例如服务、值对象)放在此处 -->
		<mx:Validator source="{username}" property="text" required="true"/>
		<mx:Validator source="{detail}" property="text" required="true"/>
	</fx:Declarations>
	<s:Panel x="10" y="26" width="250" height="200">
		<s:Label x="16" y="10" text="用户名:" height="22" width="66"/>
		<s:TextInput x="90" y="10" id="username" />
		<s:Label x="14" y="39"  text="备    注:" width="55" height="23"/>
		<s:TextArea x="90" y="40" id="detail" height="102" width="128"/>
	</s:Panel>
</s:Application>