0 Replies Latest reply on Apr 17, 2011 2:56 PM by MadMich

    Validation

    MadMich Level 1

      I need to pair up Text Fields with Button Fields (Field.0/Button.0, Field.1/Button.1 etc...)

      So how do you check a text field and a button caption for the same result in an array?

       

      Here is what I have done, but the array bit is a bit dodgy! Am I in the right direction?

       

      function Validate() {

      var rFields = new Array(

      ["Field.0"&&"FieldButton.0",  "Field.0"],

      ["Field.1"&&"FieldButton.1",  "Field.1"],

      ["Field.2"&&"FieldButton.2",  "Field.2"]);

       

       

      var bComplete = true; // assume true

       

      var errMsg = "";

       

      for (i = 0; i < rFields.length; i++) {

       

      // check for empty field

      if (this.getField(rFields[i][0]).valueAsString == "Ying") {

      bComplete = false; // stop submission

      errMsg = errMsg + rFields[i][1] + rFields[i][1] +"\n"; // add field description and new line to errMgt

      this.getField(rFields[i][0]).strokeColor = [ "CMYK", 0,0.5,0.5,0 ]; // highlight the field

      this.getField(rFields[i][0]).value = "Yang"; // Insert Yang value

      } // end missing value

       

       

      if (this.getField(rFields[i][0]).type == "button" & this.getField(rFields[i][0]).buttonGetCaption("Ying") {

      bComplete = false; // stop submission

      errMsg = errMsg + rFields[i][1] + "\n"; // add field description and new line to errMgt

      this.getField(rFields[i][0]).strokeColor = [ "CMYK", 0,0.5,0.5,0 ]; // highlight the field

      this.getField(rFields[i][0]).buttonSetCaption = ("Yang")

      } // end missing value

       

       

      }

      if (bComplete != true) {

      app.alert("Please check fields marked 'Yang' \n\n" + errMsg, 1, 1);

      }

      return bComplete;

      }