If zip code starts with a zero, then the first zero from the zip code should be dropped
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2023 04:10 AM
Hi All,
I have a requirement where, If zip code starts with a zero, then the first zero from the zip code should be dropped.
for eg : 03011 should show as 3011.
Can someone please help me with the below script corrections.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var pc = g_form.getValue('postal_code');
if (pc.indexOf('0') == 0) {
alert('pc contains' +pc);
g_form.setValue('postal_code', pr.trim(1));
}
}
2 REPLIES 2

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2023 04:23 AM
Hi,
Try below script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var pc = g_form.getValue('postal_code');
alert(pc);
if (pc.indexOf('0') == 0) {
alert('pc contains' +pc);
g_form.setValue('postal_code', pc.substring(1));
}
}
I hope client script is configured to run on change of 'Postal Code' field.
Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande
Thanks
Anil Lande
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2023 05:03 AM
Use substring() instead of trim()
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,
Piyush Sain
Regards,
Piyush Sain