15 Replies Latest reply on Jul 12, 2013 2:22 PM by sams screen name

    Validate numbers and some characters in a form field.

    sams screen name

      Dear all

      I am creating a form and in it, there are fields for email and phone number.

      I found http://forums.adobe.com/thread/857974

      to be really useful in helping me validate my email field.


      Then I tried to tweak that for the phone number field which I need to only allow the characters 1234567890+()

      As you can see, its just numbers and +(). How to I restrict the field to only accept those characters?


      I tried this but it failed:


      // Custom Validate script for text field

      (function () {


                var val = String(event.target.value);


                // Do nothing if the field is blank

                if (!val) return;


                // If the value is not a valid telephone number...

                if (!val.match(/\+?[0-9\(\)]*/)) {


                          // ...let the user know the value is not a valid telephone number...

                          app.alert("Please enter a telephone number, eg +012(3)123123123", 3);


                          // ...and set the focus back to this field





      But it does not work. Sigh.

      I have 0 background in computer language (I'm a biologist, and this is a form for doctors to fill up patient data), and would appreciate some help in getting the phone field validation to work.