Prevent line break in multi line text field

gnunez
Kilo Guru

Hello all,

Does anyone know if theres a way to prevent line breaks in a multi line text field?

We have an integration with DocuSign so when the user submits the form it got the error "String contains control character". When comparing to other forms the user had used enter for a new line which caused the issue. If the user just types away and goes onto the second line it was fine.

I want to see if theres a way to prevent the user from clicking enter or if theres a way to remove the line break after the form has been submitted.

Any assistance with this would be greatly appreciated!

Thanks in advance,

Grace 

1 ACCEPTED SOLUTION

Hi Grace,

Please replace trim() for this:

 

replace(/\r?\n|\r/g, "");

 

Example:

var str = "test 1\n"+
" test2\n"+
" test 3";
str = str.replace(/\r?\n|\r/g, "");

 

Result: test 1 test2 test 3

 

Regards,

Pedro Lopez

View solution in original post

12 REPLIES 12

Hi Pedro,

Let me explain a bit more and I hope it makes sense.

Once the form is submitted the fields populate on the DocuSign form but when there is a line break an error occurs so this is what we would like to achieve:

Currently in the multiline text field(when a user selects enter for the break):

I would like to request

a ServiceNow developer instance.

I would like for the line break to be removed or at least an error message given when a requester is trying to submit. Something that notifies them to remove any line break because we would like to have something like this:

Field:

I would like to request a ServiceNow developer instance.

 

Hope this better explains things....

 

Grace

Hi Grace,

Please replace trim() for this:

 

replace(/\r?\n|\r/g, "");

 

Example:

var str = "test 1\n"+
" test2\n"+
" test 3";
str = str.replace(/\r?\n|\r/g, "");

 

Result: test 1 test2 test 3

 

Regards,

Pedro Lopez

Yes Pedro this is exactly what we were looking for!!

Thank you so much for your help!

For the wording I noticed there isn't a space between sentence, so is there a way to add that? If that makes things to completed I will leave as is, because it isn't required just a nice to have. 

currently: This is a test.For the line breaks.I am a test.

like to have: This is a test. For the line breaks. I am a test.