These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

How do you create two text fields but can only type in one?

Abbica
Registered: Feb 4 2009
Posts: 38
Answered

Hi, I have two text fields, (i) & (ii). They only want you to enter into either, or. Does anyone know how I do this. I know how to do it with radio buttons etc but not text fields, is there script I require to do this and if so, does anybody know it please? Really desperate with this.

My Product Information:
Acrobat
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
Accepted Answer
You could use a custom Validate script for each field. It would set the other field to readonly and clear it if the field has a value. For example:

  1. var f = getField("t2");
  2.  
  3. if (event.value) {
  4. f.value = "";
  5. f.readonly = true;
  6. } else {
  7. f.readonly = false;
  8. }
If there's not text in either field, the user can enter text in either one.

Change "t2" to the actual name of the other field, and use the same script in the Validate event of the other field, but change "t2" to "t1", but use the actual name of the first field.
fetto
Registered: Mar 18 2011
Posts: 1
excactly what i needed :)
n/a
Abbica
Registered: Feb 4 2009
Posts: 38
Hi George, thank you so much for that script, exactly what I was after. Thanks.
Merlin
Acrobat 9ExpertTeam
Registered: Mar 1 2006
Posts: 766
If the 2 text fields shares exactly the same name, their appearance should be different but other properties are shared : filling one field means filling both fields as same.

;-)