Note that there are some explanatory texts on larger screens.

plurals
  1. POFlex Conditional Validation
    primarykey
    data
    text
    <p>I'm trying to do validation on three fields in an mxml file. Two of them are required, one isn't. The zip code field I only want to be validated if something is entered into it. If it's blank, then I want to allow the 'submit' button to be enabled, as long as the other two required fields are correctly set. Code:</p> <pre><code>&lt;mx:EmailValidator id="emailValidator" property="text" source="{ownerName}" valid="emailValidator_validHandler(event)" invalid="emailValidator_validHandler(event)"/&gt; &lt;mx:ZipCodeValidator id="zipCodeValidator" property="text" source="{zip}" required="false" valid="zipCodeValidator_validHandler(event)" invalid="zipCodeValidator_validHandler(event)"/&gt; &lt;mx:Validator id="roomNameValidator" property="text" source="{roomName}" valid="roomNameValidator_validHandler(event)" invalid="roomNameValidator_validHandler(event)"/&gt; [Bindable] private var isRoomNameValid:Boolean; [Bindable] private var isOwnerValid:Boolean; [Bindable] private var isZipValid:Boolean; protected function emailValidator_validHandler(event:ValidationResultEvent):void { isOwnerValid = (event.type==ValidationResultEvent.VALID); } protected function zipCodeValidator_validHandler(event:ValidationResultEvent):void { isZipValid = (event.type == ValidationResultEvent.VALID); } protected function roomNameValidator_validHandler(event:ValidationResultEvent):void { isRoomNameValid = (event.type==ValidationResultEvent.VALID); } </code></pre> <p>I then tried to set the enabled property of the submit button:</p> <pre><code> enabled = "{isOwnerValid &amp;amp;&amp;amp; isRoomNameValid &amp;amp;&amp;amp zip.text.length&gt;0?isZipValid:true}" </code></pre> <p>But it doesn't work. I can still submit bad data in the zip field, even though the zip code field shows the red border.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload