Skip to main content
Known Participant
August 9, 2018
Answered

Disable enter key on text field

  • August 9, 2018
  • 1 reply
  • 1038 views

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,

This topic has been closed for replies.
Correct answer try67

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;

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
August 9, 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;

lapnetoAuthor
Known Participant
August 9, 2018

Works like a charm!

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

Best Regards,