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

Make field read only if other is not blank, and vice versa

Guest
Jul 01, 2016 Jul 01, 2016

Hello,

I have this form where two fields cannot have a value at the same time: if one is filled, the other must be set read-only. I tried adding the following script as a custom calculation in both fields (say, name1 and name2):

In the field Name2:

if (event.value=="")

{this.getField("Name1").readonly = true}

else

{this.getField("Name1").readonly = false}

Similarly, I use the same script (changing "name1" to "name2"), which results in both fields being read-only.

I would need both of them to be fillable until one is not blank anymore. It would be great if, when erasing the data from that field, the other became fillable again (in case it was a mistake), although I don't know if that would be possible.

Also, and forgive me if I should have posted a different question for this, I would like to know if there is a way to show something similar to a non-printable comment (not popup, I wouldn't want to have to close it everytime) once either of the two is active with a warning about the other field being locked. Everything I've found is about either tooltips or pop-ups, but I have been unable to find this particular case.

Thank you!

TOPICS
Acrobat SDK and JavaScript , Windows
241
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
no replies

Have something to add?

Join the conversation