Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Enter on X or N/A in a text field

New Here ,
Mar 03, 2017 Mar 03, 2017

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

TOPICS
Acrobat SDK and JavaScript , Windows
740
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 03, 2017 Mar 03, 2017

You can use the Custom Keystroke or Validation actions.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 03, 2017 Mar 03, 2017

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 03, 2017 Mar 03, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 03, 2017 Mar 03, 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);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 03, 2017 Mar 03, 2017
LATEST

That worked great gkaiseril! Thanks so much.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines