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

Disable enter key on text field

Community Beginner ,
Aug 09, 2018 Aug 09, 2018

Copy link to clipboard

Copied

Hey everyone,

Hope all is well.

I am trying to prevent the user from hitting the enter key on a multi-line text field. It is important that the field has 512 characters and I have already limited it upon formatting.

However, whenever the individual uses Enter to write in another line, it appears that something happens and when I import the data there seems to be more characters (?) and I get an error. If the same text is entered but no enter key has been pushed, I can successfully import.

Is there any way I can prevent the user from hitting key 13?

I looked around and it seems to be something related to preventDefault, so would appreciate if someone could point me in the right direction or share any piece of code that could be used.

Many thanks,

TOPICS
Acrobat SDK and JavaScript , Windows

Views

181

Likes

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Expert , Aug 09, 2018 Aug 09, 2018

Yeah, it's possible. Use this code as the field's custom Keystroke field (select Custom under Format to gain access to it):

event.rc = /[\r\n]/.test(event.change)==false;

Likes

Translate

Translate
Community Expert ,
Aug 09, 2018 Aug 09, 2018

Copy link to clipboard

Copied

Yeah, it's possible. Use this code as the field's custom Keystroke field (select Custom under Format to gain access to it):

event.rc = /[\r\n]/.test(event.change)==false;

Likes

Translate

Translate

Report

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 Beginner ,
Aug 09, 2018 Aug 09, 2018

Copy link to clipboard

Copied

LATEST

Works like a charm!

Thank you so much for your help, it is much appreciated!

Best Regards,

Likes

Translate

Translate

Report

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