3 Replies Latest reply on Jun 24, 2008 11:27 AM by flatpickinJohn

    Validation Test

    flatpickinJohn

      What I'd like is a Button control that is disabled until all TextInput field contains are valid. What I have is a button that is enabled allowing me to submit without validating all TextInput entries. The only way to disable the button is to select and deselect any TextInput control that requires data or viilating another validation rule on any TextImput control.

      How can I either disable the button until all TextInput controls pass validation or allow a submit but catch it and require user to correct highlighted TextInput controls that do not pass validation.

      Here's my code:

      <?xml version="1.0"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" creationComplete="initApp()" initialize="Main()" width="1300" height="800" layout="absolute" verticalScrollPolicy="on" enabled="true" includeInLayout="true" visible="true" horizontalScrollPolicy="on" xmlns:ns1="components.*" >
      <!--xmlns:custom="components.*">-->
      <!--creationComplete="initApp()"-->
      <mx:XMLListCollection id="dpAccordionXML" source="{populateContactXML}"/>

      <!-- Define the validators. -->
      <!-- Name & Address Block. -->
      <mx:StringValidator id="nameV"
      required="true"
      source="{SE_Company_Name}"
      property="text"
      valid="handleValid(event);"
      invalid="handleValid(event);"/>

      <mx:StringValidator id="address1V"
      required="true"
      source="{Address_1}"
      property="text"
      valid="handleValid(event);"
      invalid="handleValid(event);"/>

      <mx:PhoneNumberValidator id="bpnV"
      required="false"
      source="{PhoneNumber}"
      property="text"
      valid="handleValid(event);"
      invalid="handleValid(event);"/>

      private var vResult:ValidationResultEvent;

      // Function to validate data it to the server.
      private function handleValid(event:ValidationResultEvent):void {
      // Validate the required fields.
      if (event.type==ValidationResultEvent.VALID)
      submitButton.enabled = true;
      else
      submitButton.enabled = false;
      return;
      // Submit form is everything is valid.
      private function submitForm():void {
      // Handle submit.
      CP_WS.set_party_xml(User_Id,CurrentToken,SearchXML.toXMLString());
      tmptxt1.text = SearchXML.toXMLString();
      }