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

readOnly disregarding setting

Participant ,
Jun 07, 2023 Jun 07, 2023

I am having an interesting issue. Which is, I created a text field, which is populated from a dropdown when the text field is visible. That part is fine. But, I've noticed the text field, set to readOnly, will disregard the readOnly setting and continue to reset the dropdown and the text field itself when clicked. The text field has a javascript to reset itself when clicked in and when visible. Is this a malfunction with my Acrobat app or is this happen when there's a script attached to the text field. I have tried to remove the javascript and only then will the text field remain readOnly. So, I start thinking, perhaps I cannot attach a javascript to the text field. I'd like to find out if there's something I can do to better understand what is happening. How can I set the text field to reset when clicked the dropdown and reset the text field itself and then when I click the popUp Menu selecting the text field to be readOnly? Can someone please let me know? Thanks folks.

TOPICS
Create PDFs , JavaScript , PDF , PDF forms
339
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 ,
Jun 08, 2023 Jun 08, 2023

The readonly attribute does not stop a field from being changed in JavaScript. That would be entirely wrong, since they are often used to give info to the user. The readonly attribute only stops the user from directly changing it (eg by typing in the text field). 

Your code can check the readonly property before taking any action, if you want.

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 ,
Jun 08, 2023 Jun 08, 2023

Also, be aware it's not readOnly, but readonly. JS is case-sensitive so the former will not work.

Confusingly, it is readOnly for Anntoations, though.

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 ,
Jun 08, 2023 Jun 08, 2023
LATEST

By clicked on, do you mean a MouseUp event?  Probably not a good idea to use this event, or any field event to perform a non-qualified reset of the field.  What you really need to do is create a complete list or table of actions and responses for the text field. This list needs to include things you don't want to happen. This will show you where conflicts exists and guide the design process. Also define your terms better. What exactly do you mean by "Clicked On" and "Reset"? Does tabbing into a field count as clicked on?  

 

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

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