5 Replies Latest reply on Oct 10, 2008 8:14 AM by George_Johnson

    Customd validation script syntax

      Hi,
      I use simple acroform created by Acrobat 9 pro with text field. On the text field properties -> validate tab I had put some custom javascript but it has never executed. Can you tell me what must be exact syntax for this script is it suppose to return boolean value or something ?
        • 1. Re: Customd validation script syntax
          gkaiseril MVP & Adobe Community Professional
          There is no return code, but you may need a custom keystroke and format scripts to support the validation script.

          The validation script for inputting the first and last name with each name must start with a capital letter followed by one or more lower case letters and separated by a blank character:

          this.getField(event.target.name).fillColor = color.transparent; //clear field background
          // create RegExp string for required format
          // First and last names begin with one capital letter followed by lower case letters
          var re = /^[A-Z[a-z]+ [A-Z][a-z]+$/;
          // use RegExp test to see if format rule followed
          if (re.test(event.value) == false) {
          app.alert("That does not appear to be a valid name. I need first and last name.", 1, 0); // error message
          // other error processing options
          this.getField(event.target.name).fillColor = color.red; // use red to highlight problem field
          // event.value = ''; // optional to force complete reentry if an error
          app.beep(1); // beep sound
          } // end validation test
          • 2. Re: Customd validation script syntax
            Level 1
            Hi,
            Thanks for the answer. Can you tell me how to make the field with wrong value to be in red color permanently not only when it is on focus ?

            Best regards !
            • 3. Re: Customd validation script syntax
              gkaiseril MVP & Adobe Community Professional
              The code should leave the field highlighted when you move to another field. Are you using the whole form highlight fields? If so try change the border color.
              • 4. Re: Customd validation script syntax
                Level 1
                Hi,
                How to change border color in the JS_Api reference I see only border style?
                • 5. Re: Customd validation script syntax
                  George_Johnson MVP & Adobe Community Professional
                  Use the strokeColor field property.

                  George