- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2016 04:49 PM
Hi All,
I am trying to populate name field on another field through client script. But I want only first 3 characters to be auto-populated. Please share your thoughts on how to achieve this?
Appreciate you Help!!
Thank you,
Jack
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2016 05:17 PM
Hi Jack,
You would do something like this with an onChange client script on field1.
var str = g_form.getValue('field1');
g_form.setValue('field2', str.substring(0, 3));
Modify 'field1' to be the name of your source field and 'field2' to be the name of your target field.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2016 05:17 PM
Hi Jack,
You would do something like this with an onChange client script on field1.
var str = g_form.getValue('field1');
g_form.setValue('field2', str.substring(0, 3));
Modify 'field1' to be the name of your source field and 'field2' to be the name of your target field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2016 06:06 PM
thanks Chuck!! its working
Can we also remove special characters?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2016 07:21 PM
You can do that with a .replace() function using a regular expression.
str = str.replace(/[^a-z0-9]/gi, ''); // strip out anything that's not a letter or number

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2016 05:48 PM