Javascript code for validating numbers

So, if the user enters ‘01234’ we should see an error message that would instruct the user about what type of data is valid for this field.

To start, we create a text field and bring up the properties dialog for the field.

The number may not, in fact, be assigned to any financial institution.

Unlike credit card numbers, ABA routing numbers are always nine digits long.

Note that even if a number passes this test, it does not necessarily mean that it is valid.

After the “Edit” button is clicked, a new window will open that allows us to edit the new script: This script also includes a check for an empty string, so that the user can wipe out a wrong string and start from scratch.

As I mentioned before, information is passed to the validation function in the event object, and in the code we see that the member ‘value’ is used to communicate the current value of the field.

Adobe provided a lot of infrastructure to do that with just a simple script.

Let’s take a look at how to do that with a text field that is only supposed to have a value of either ‘AAAA’ or ‘BBBB’ (yes, I know that this does not make much sense in a real PDF form).