- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-09-2018 02:39 PM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-12-2018 09:21 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-10-2018 10:52 AM
Hi Grace,
I will recommend to do it onSubmit. It means, the script will run once you submit the record and you can make the validation. Try this:
OnSubmit:
var descriptionOldValue = g_form.getValue('description');
var descriptionNewValue = descriptionOldValue.trim();
g_form.setValue('description', descriptionNewValue);
Hope this helps,
Pedro Lopez
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-10-2018 02:26 PM
Hi Pedro,
I tested with your suggested code but the line break is still there.
I also have another field "request_purpose" that has the same requirement and tried with that as well but still no luck. š
Thanks,
Grace
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-10-2018 03:33 PM
Hi Grace,
Can you add an alert at the end of your code, please? And Can you share here the response, please? It is working in my side, I just want to know how you are doing it.
//add this alert
alert(descriptionNewValue);
Regards,
Pedro Lopez
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-10-2018 03:51 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-10-2018 04:48 PM
Hi Grace,
Can you tell me what is the expected behavior, please? The code seems to be working. The code will remove the extra lines (white spaces). Example:
String: " My testing ";
Result: "My testing";
Can you explain more in details the expected result you would like to see, please?
Regards,
Pedro Lopez