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

Pedro Lopez
Kilo Guru

Hi,

Try to remove the line break by using trim(). Example:

 

var str = " abc de fog   ";
str.trim();

 

Hope this helps,

Pedro Lopez

Thanks Pedro for the reply! Would this be added in the variable attributes?

Thanks,

Grace

Hi Grace,

In this case, you will need to validate the information contained in your multi line text. You can do it by using an script: OnLoad, OnChange or OnSubmit, depending of your needs. Let me know if you need help with the code.

 

Regards,

Pedro Lopez

Hi Pedro,

Got it thanks. I am not an expert at coding so your help would be greatly appreciated.

Since I want to validate before they submit the item then it should probably onChange correct?

The variable I am trying to validate is "Description" and the field name is description.

Thanks,

Grace