commit selected value immediately in plain text box
Copy link to clipboard
Copied
Is there a way to "commit selected value immediately" in a plain text box, like you can by checking that box on the options tab of a dropdown? Rather than it committing once the return key is pressed or the user tabs to the next field?
Copy link to clipboard
Copied
Hi,
Can you give more context?
I think it makes sense that the content is checked/validated/commited once the user clicks away.
I am not sure there is a 'dynamic' approach to this. Checkboxes and dropdowns only react to clicks, same here, even if you create some validation rules, or scripting.
Copy link to clipboard
Copied
This would be nice in any type of text box, whether a number or plain text.
The one I'm really interested in is a text box that is populated by answering a response dialog (app.response). The text box itself is "Date1", etc. It is either a single or two digit number (though not a number field) or a range like 7-14. Hopefully you get the idea.
Copy link to clipboard
Copied
It's not possible to do that with a response dialog. What you can do, though, is put the call to the response command in a loop, verifying the user's input each time they enter it, until they get it right.
Copy link to clipboard
Copied
That's what the Keystroke event is for. You can use it to validate the user's input as they are typing it.
Copy link to clipboard
Copied
I'm a total newbie to Acrobat and this page was the first that turned up on my search for "pdf form commit immediately text field script". Reading your reply to another user, this might not be exactly what you were meaning, but I decided to write this here in case some other newbie stumbles upon this page when looking for a way to have a text field immediately commit a custom script, that is, show the result as the text is being typed.
try67's answer ("That's what the Keystroke event is for.") points to what I was looking for, but because I'm a totally inexperienced user, the solution wasn't as obvious to me, even after googling for "keystroke event". So, to spell it out more minutiously, this is what worked for me:
In the Text Field Properties window,
- I went to the Format tab,
- changed Select format category to "Custom",
- and then pasted my script in the Custom Keystroke Script section.
It was a simple script to change input to uppercase using event.change, which I now realise only works in this Keystroke section.
What I was doing wrong was using the Custom Validation or Custom Calculation Script sections (those worked for other scripts that I had to use in other fields, but I had no understanding of the differences between those, and it doesn't help that the Custom Keystroke Script section only shows up if you select the correct format category).

