- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2023 12:26 AM
var regex = /[0-9]{5}(?:-[0-9]{4})?$/;
if (!regex.test(newValue)) {
g_form.showFieldMsg('property_zip_code', 'Please enter a valid zip code #####', 'error');
return false;
}
return true;
}
Its working but if i give more than 5 digits its taking can anyone help me with this !!!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2023 12:44 AM - edited 08-25-2023 12:45 AM
Hello @Trupti Krishnam ,
Try the modified regex:
if (!/^[0-9]{5}$/.test(newValue)){
g_form.showFieldMsg('property_zip_code', 'Please enter a valid zip code #####', 'error');
return false;
}
Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2023 12:39 AM
Hi
Please try to use:
var regex = /^[0-9]{5}$/;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2023 12:44 AM - edited 08-25-2023 12:45 AM
Hello @Trupti Krishnam ,
Try the modified regex:
if (!/^[0-9]{5}$/.test(newValue)){
g_form.showFieldMsg('property_zip_code', 'Please enter a valid zip code #####', 'error');
return false;
}
Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2023 12:51 AM
Thank you 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2023 12:55 AM
Hi Trupti,
Please try below Regex