Skip to main content
rboswell
Participant
March 3, 2017
Question

Enter on X or N/A in a text field

  • March 3, 2017
  • 2 replies
  • 832 views

How can I limit entry in an acrobat fill-in form text field to only "X" or "N/A"?

This topic has been closed for replies.

2 replies

try67
Community Expert
Community Expert
March 3, 2017

Or use a drop-down field instead of a text field...

rboswell
rboswellAuthor
Participant
March 3, 2017

There are sixteen fields where we only want to allow an X or N/A.  The drop down box and list box do not look good on the form.  We want a text field that only allows one of the two entries.

Inspiring
March 3, 2017

Then I would write a document JavaScript level function for the custom keystroke or validation and call that function or functions in the custom keystroke or validation as needed.

I would use the following Custom KeyStroke script  to convert each key entered to upper case:

if(!event.willCommit)

{

event.change = event.change.toUpperCase();

}

I would create a document level function that verifies a string is either an empty string, an "X", or "N/A". It returns logical true value if either of those conditions is met. This returned value can be used to set the return code for a validation script.

function XNA(cString)

{

var RC = true;

cString = cString.toUpperCase();

if(cString != "X" && cString != "N/A" && cString != "")

{

  app.alert("Enter 'X' or 'N/A'", 1, 0);

  RC = false;

}

return RC;

} // end function XNA which tests a String for being X, N/A or a null string;

I can then have a validation script like:

event.rc = XNA(event.value);

Inspiring
March 3, 2017

You can use the Custom Keystroke or Validation actions.