8 Replies Latest reply on May 26, 2010 1:57 PM by caeriel

    Regular Expression in Field Validation not working.

    caeriel

      I sure hope someone can help me.  I'm fairly conversant with regular expressions but for some reason I can't get this one to work.

      Environment: WindowsXP

      Adobe Acrobat v8.12

       

      Scenario:

      User enters a complete path into a form text field.

       

      This is the code that is executed when the user leaves the field:

      /*  Test alternatives

       

      //  var validChars = /^\w[ :\\]$/
      //  var validChars = /^\w :\\$/

      //  var validChars = /^[A-Z][a-z][0-9][ :\\_]$/

       

      */


      var validChars = /^[A-Za-z0-9 :\\_]$/

       

      if (event.value != "")
      {
            if (validChars.test(event.value) == false)
            {
                  app.alert("Invalid character.  Only alphanumeric, colon, underscore, backslask, and spaces are valid characters.");
                  event.rc = false;
            } 
      }

       

      The characters permitted in the path are: alphanumeric, underscore, colon, backslash(\) and space.

      I've tried all of the above expressions with      c:\aoa_apps      and they all fail:  The Invalid Character alert pops up.

       

      I've added alerts to print out the event.value and that appears to be ok.

       

      I've even tried each of them with  c:aoa_apps and they still fail.  Finally, I tried caoa_apps and they still fail.

       

      I've verified each of the expressions in a little expression validator I have and they appear to be ok.

       

      I'm cross-eyed looking for some reason why this is failing.   I'm new to scripting Adobe Acrobat so apparently I'm doing something stupid, again.  But for the life of me, I can't see it.

       

       

      Can anyone spot the problem?

       

      Any help is greatly appreciated.

       

      caerial.