- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2021 05:48 AM
Hello I have requirement, wherein if a user types in the variable (select box) - "this is a test name" then it should display as "thisisatestname" in the RITM and task. I have written the below simple code but doesn't work.
OnSubmit Client script
function onSubmit() {
//Remove spaces from the field
var first = g_form.getValue('variable1');
g_form.setValue('variable1',first.trim());
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2021 06:12 AM
Hi
Instead of trim use replace method.
Thanks & BR,
Murthy
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2021 05:58 AM
Hi Jo,
The trim method only removes any leading and trailing spaces in a string. Instead, try the replace method
g_form.setValue('variable1',first.replace(/ /g, ''));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2021 06:12 AM
Hi
Instead of trim use replace method.
Thanks & BR,
Murthy
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2021 06:25 AM
Hi Brad, Murthy, thank you for your responses. I tried replace too, but no difference.
var first = g_form.getValue('variable1');
var trimnm = first.replace(/ /g, '');
g_form.setValue('variable1',trimnm);
Didn't work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2021 07:12 AM
Hi
Try this
var first = g_form.getValue('variable1');
var trimnm = first.split(" ").join("");
g_form.setValue('variable1',trimnm);
Let me know, if it worked
Please mark my answer as correct /helful, if your issue is resolved