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

SET TEXTBOX READONLY VALUE BASED ON WHETHER ANOTHER TEXTBOX HAS A VALUE

New Here ,
Feb 13, 2023 Feb 13, 2023

Copy link to clipboard

Copied

I have a form with several textboxes that are set initially to ReadOnly. What I am looking for is how do I change the "readonly" status of TextBox 2, if data is entered in another TextBox (i.e., TextBox 1)?

 

I have tried the following using the action "Mouse Exit", "Run a Javascript" in TextBox 1, with no satisfaction:

 

if (event.target.value != "")

     {

          this.getField("TextBox 2").readonly = false;

          this.getField("TextBox 2").setFocus();

     }

else

     {

          this.getField("TextBox 2").readonly = true;

     }

 

Any help would be greatly appreciated. Thank you in advance.

TOPICS
Create PDFs , How to , JavaScript , PDF forms

Views

598

Translate

Translate

Report

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 ,
Feb 13, 2023 Feb 13, 2023

Copy link to clipboard

Copied

LATEST

The correct way to do this is a custom validation script on "TextBox 1". Delete the MouseExit script.

if (event.value != "")
{
    this.getField("TextBox 2").readonly = false;
    this.getField("TextBox 2").setFocus();
}
else
     this.getField("TextBox 2").readonly = true;

 

However, your script should have worked as is.  Are any errors reported in the Console Window (press Ctrl-J)?

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

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