急!!!flex表单验证问题—同时验证两个文本框中必须填写其中一个,用flex的StringValidator怎么验证的?
RT
[解决办法]
这样子写:
<?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:VerticalLayout paddingLeft="40" paddingTop="40"/> </s:layout> <fx:Script> <![CDATA[ import mx.controls.Alert; import mx.events.ValidationResultEvent; protected function button1_clickHandler(event:MouseEvent):void { // TODO Auto-generated method stub if (stringValidator1.validate().type == ValidationResultEvent.VALID || stringValidator2.validate().type == ValidationResultEvent.VALID) Alert.show("两者必须填写一个的情况成功发生。", "演示"); } ]]> </fx:Script> <fx:Declarations> <!-- Place non-visual elements (e.g., services, value objects) here --> <mx:StringValidator id="stringValidator1" source="{this.textInput1}" property="text" required="true"/> <mx:StringValidator id="stringValidator2" source="{this.textInput2}" property="text" required="true"/> </fx:Declarations> <s:TextInput id="textInput1" /> <s:TextInput id="textInput2" /> <s:Button label="演示" click="button1_clickHandler(event)"/></s:Application>