flexのStrigValidator

2104 ワード

<?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:Script>
		<![CDATA[
			import mx.controls.Alert;
			import mx.events.ValidationResultEvent;
			protected function userNameValidator_validHandler(event:ValidationResultEvent):void
			{
				Alert.show("      ");
			}
			protected function userNameValidator_invalidHandler(event:ValidationResultEvent):void
			{
				Alert.show("         ,     ");
			}
		]]>
	</fx:Script>
	<fx:Declarations>
		<!--       (    、   )     -->
		<mx:StringValidator
			id="userNameValidator"
			enabled="true"
			source="{username}"
			property="text"
			required="true"
			requiredFieldError="         "
			maxLength="6"
			tooLongError="          6   "
			minLength="1"
			tooShortError="          1   "
			listener="{errorInfoUsername}"
			valid="userNameValidator_validHandler(event)"
			invalid="userNameValidator_invalidHandler(event)"
			trigger="{submitButton}"
			triggerEvent="click"
			/>
	</fx:Declarations>
	
	<s:VGroup horizontalCenter="0" verticalCenter="0">
		<s:Label text="      :"/>
		<s:TextInput id="username"/>
		<s:Label text="                   "/>
		<s:TextInput id="errorInfoUsername"/>
		<s:Button label="Submit" id="submitButton"/>
	</s:VGroup>
</s:Application>