Skip to main content
alexandrubarbu
Participant
October 22, 2019
Question

when text field length = 4, go to the next text field

  • October 22, 2019
  • 1 reply
  • 1454 views

Hi,

 

I am preparing a form in Adobe Acrobat Pro DC,

 

I am trying to format my text fields, currently, I have 4 text fields each with a character limit of 4, and when that limit is reached then I want the user to automatically be moved into the next text field.

 

I have tried using the following javascript in the custom keystroke script:

 

if (event.value.length = 4) {

     getField("txb2").set Focus();

}

 

Although this isn't working as after I enter 1 character I am then directed to the next field.

I want to be able to type 4 characters in a text field, then to go to the next text field automatically.

 

If someone can please help me out, that would be greatly appreciated.

 

Thanks

    This topic has been closed for replies.

    1 reply

    try67
    Community Expert
    Community Expert
    October 22, 2019

    Use this code as the custom Keystroke script:

    if (AFMergeChange(event).length==4) this.getField("txb2").setFocus();


    It's possible the code will "disappear" after you enter it. That's OK, it should still work.

    alexandrubarbu
    Participant
    October 25, 2019

    Thank you try61,

     

    The script you provided was very helpful!

     

    try67
    Community Expert
    Community Expert
    October 25, 2019

    Keep in mind that this script will not prevent someone from going back to the field and enter more text into it, so you might want to also set the character limit of the field to 4.