Required fields in flex

I have a question about flex. I have a form and a letter is required. I googled this and found the following solution:

<mx:FormItem label="Email" id="emailFormItem"  width="100%" styleName="formEven" required="true">                   
<mx:TextInput id="emailTextInput" width="100%" text="{user.email}"/></mx:FormItem>

The problem is that when I click ok, the call is still being made. I know you need to check this yourself, but does anyone have an idea how I can check the field?

Decision:

I found a solution for this:

You can create a validator for each field that you want to check, and then create this function:

private function isValid():Boolean {
            var failedValidators:Array = Validator.validateAll([emailValidator, userNameValidator, languageValidator, firstNameValidator, lastNameValidator]);
            return failedValidators.length == 0;
        }

It may be closed.

+3
source share
2 answers

, , , isSubmitEnabled isFormComplete. keyUp , , ( , ), , , , , . , .

. , , .

:

:

. , .

mx.validators.Validator(http://livedocs.adobe.com/flex/3/langref/mx/validators/Validator.html)

 <mx:Validator id="reqValid" required="true"
    source="{fname}" property="text" 
    valid="handleValid(event)" invalid="handleValid(event)"/>

. , , . , , , , .

+2
<fx:Declarations>
        <mx:RadioButtonGroup id="a1" itemClick="usdradio(event);"/>
        <fx:Model id="creditcard">
            <card>  
                <cardType>{cardTypeCombo.selectedItem.data}</cardType>
                <cardNumber>{cardNumberInput.text}</cardNumber>
            </card>
        </fx:Model>
        <mx:CreditCardValidator id="ccV" 

                                cardTypeSource="{creditcard}" cardTypeProperty="cardType"
                                cardNumberSource="{creditcard}" cardNumberProperty="cardNumber"
                                trigger="{myButton}" triggerEvent="click"
                                cardTypeListener="{cardTypeCombo}"
                                cardNumberListener="{cardNumberInput}"
                                valid="Alert.show('Validation Succeeded!')"/>

        <mx:ArrayCollection id="dp">
            <fx:Object label="American Express" data="American Express"/>
            <fx:Object label="Diners Club" data="Diners Club"/>
            <fx:Object label="Discover" data="Discover"/>
            <fx:Object label="MasterCard" data="MasterCard"/>
            <fx:Object label="Visa" data="Visa"/>
        </mx:ArrayCollection>

        <mx:CurrencyValidator source="{priceUS}" property="text" precision="2" 


                              trigger="{myButton2}" triggerEvent="click" 
                              valid="Alert.show('Validation Succeeded!')"/>
0

Source: https://habr.com/ru/post/1703807/


All Articles