0
하나의 파일 만 유효성을 검사 할 수 있습니다.flex : 여러 필수 필드의 유효성을 검사하는 방법
<mx:Validator required="true" property="text" source="{name}" valid="vaildator(event)" invalid="vaildator(event)" />
감사
하나의 파일 만 유효성을 검사 할 수 있습니다.flex : 여러 필수 필드의 유효성을 검사하는 방법
<mx:Validator required="true" property="text" source="{name}" valid="vaildator(event)" invalid="vaildator(event)" />
감사
사용 Validator.validateAll() 함수는 각 필드의 유효성을 가져온 다음 반환 된 배열이 비어 있는지 확인합니다.
<?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:Declarations>
<mx:StringValidator
id="svSurname"
source="{tiSurname}"
property="text"
requiredFieldError="Surname is required!"
required="true"/>
<mx:StringValidator
id="svFirstname"
source="{tiFirstname}"
property="text"
requiredFieldError="Firstname is required!"
required="true"/>
<mx:NumberValidator
id="nvAge"
source="{tiAge}"
property="text"
lowerThanMinError="Only after 18 years old"
minValue="18"
requiredFieldError="Age is required!"
required="true"/>
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.validators.Validator;
private function onBtnEnter():void
{
var validationResult:Array = Validator.validateAll([svSurname, svFirstname, nvAge]);
if (validationResult.length == 0)
Alert.show("All right!");
else
Alert.show("You have an error!");
}
]]>
</fx:Script>
<s:VGroup x="10" y="10" width="250" height="150">
<s:HGroup width="100%" verticalAlign="bottom">
<s:Label text="Surname*" width="120" textAlign="right"/>
<s:TextInput id="tiSurname" width="120"/>
</s:HGroup>
<s:HGroup width="100%" verticalAlign="bottom">
<s:Label text="Firstname*" width="120" textAlign="right"/>
<s:TextInput id="tiFirstname" width="120"/>
</s:HGroup>
<s:HGroup width="100%" verticalAlign="bottom">
<s:Label text="Age*" width="120" textAlign="right"/>
<s:TextInput id="tiAge" width="120"/>
</s:HGroup>
<s:HGroup horizontalAlign="center" width="100%" height="40">
<s:Button id="btnEnter" label="Send" click="onBtnEnter()"/>
</s:HGroup>
</s:VGroup>
</s:Application>
음, 더 많은 검사기를 추가하십시오. – RIAstar
각 필드에 유효성 검사기를 정의해야합니다. Validation Giude Line http://livedocs.adobe.com/flex/3/html/help.html?content=validators_2.html을 살펴보십시오. 또한 여러 필드 및 유효성 검사기가있는 좋은 예가 있습니다. – Panciz