SET TEXTBOX READONLY VALUE BASED ON WHETHER ANOTHER TEXTBOX HAS A VALUE
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.
Copy link to clipboard
Copied
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)?
Use the Acrobat JavaScript Reference early and often

