Skip to main content
October 24, 2016
Question

I want to create a text box that only allows a tick, N/A, A, R, X & D and will auto capitilise. I have 42 of these text boxes on my document!

  • October 24, 2016
  • 3 replies
  • 872 views

I am trying to create 42 text boxes that will only allow the user to enter the following: a tick (check), N/A, A, R, X & D.  I would also like it to auto capitalise.  I'm using acrobat pro & am very new to form design and javascript.  I would appreciate any help because the coding I've found so far doesn't work!

I have entered as custom keystroke script

// Allow just the letter specified

function alphaOnly_ks()

event.change = event.change.toUpperCase()

and in my page actions:

// Allow just the letter specified

function alphaOnly_ks() {

    // Get all of the characters that have been entered in to the field

    var value = AFMergeChange(event);

    // Do nothing if field is blank

    if(!value) return;

    // Reject the entry if the entry doesn't match the regular expression

    if(!AFExactMatch(/^[✓,N/A,A,R,X,Dn/a,a,r,x,d\s\/]+$/, value)) event.rc = false;

}

This topic has been closed for replies.

3 replies

October 24, 2016

Thank you for your replies!

try67 - I did this originally but, the forms are for my brother to use on an iPad Air using PDF Max 5 Expert and the dropbox appears large and to the left, which covers the questions ... it also does not disappear until you tab through the form, which is a bit cumbersome.

gkaiseril - a) it doesn't matter - whichever is easier!

                b) for ease of use (as it is on an iPad using PDF Max 5 Expert), I think it would be better to block as                        they are attempted to be entered.

               c) The max amount of characters can only be N/A, but they should not be able to answer A & D for example.  The answer can only be one of the choices so a tick or N/A or. A etc.

try67
Community Expert
Community Expert
October 25, 2016

Most scripts don't work at all, or only partially, on mobile devices. It depends a lot on the device and on the app used to open the file. I'm not familiar with the app you mentioned but the best one for iOS devices is Readdle's PDF Expert.

I would go for a slightly cumbersome, but simple, solution than for one that is complicated to create and might not work at all...

October 25, 2016

Thank you try67 ... that's the app he has.  Is is possible then to make the dropdown box appear at the bottom of the page?  The form I am creating is a very detailed worksheet; basically a checklist.  It has 42 categories which are lines of instructions/things to check and therefore would have 42 very small dropdown's that are aligned one below the other. 

Sorry if I seem ignorant of the basics.  This is the first time I have tried to do this and it seems there is a lot I need to learn!

Inspiring
October 24, 2016

Do you want to change the entered text to all caps as the text is entered or after the text has been entered.

Do you want to block any characters not in your list as they are attempted to be entered or on exit from the field?

How many characters will you allow to be entered?

October 25, 2016

gkaiseril - a) it doesn't matter - whichever is easier!

                b) for ease of use (as it is on an iPad using PDF Max 5 Expert), I think it would be better to block as                        they are attempted to be entered.

               c) The max amount of characters can only be N/A, but they should not be able to answer A & D for example.  The answer can only be one of the choices so a tick or N/A or. A etc.

try67
Community Expert
Community Expert
October 24, 2016

Why not simply use a drop-down menu?