- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2020 08:50 AM
Greetings,
I'm trying to write an onChange catalog client script to check a string variable for beginning and trailing spaces. If found, give the user an error message and set the value to null. Everything I've tried hasn't worked. Does anyone have the code to accomplish this?
Thanks in advance!
-Skip
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2020 09:01 AM
I haven't tried this, but maybe use the 'trim' method. If you go this route, it would likely be better as an On Submit Client Script, otherwise it would run and run since you are setting the value on the same variable causing the on-change to run.
var str = g_form.getValue('variable_1');
var wsr = str.trim();
g_form.setValue('variable_1',wsr );
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2020 09:01 AM
I haven't tried this, but maybe use the 'trim' method. If you go this route, it would likely be better as an On Submit Client Script, otherwise it would run and run since you are setting the value on the same variable causing the on-change to run.
var str = g_form.getValue('variable_1');
var wsr = str.trim();
g_form.setValue('variable_1',wsr );
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2020 10:10 AM
That worked...thanks!