- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2025 01:10 AM
I am using the GlideElementPhoneNumber since its an OOTB to validate if phone is valid.
My question is how can we validate if the user input a mobile phone number format into business phone and make it as invalid ?
this is a business phone and its ok
this is a mobile phone and still shows a valid phone
my thinking is i will use a field in a user field then input the format for Business Phone and validate it if its written the same in business phone field then its valid instead of using OOTB.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2025 01:41 AM
Hi @Jeck Manalo,
Please create OnChange Catalog Client Script for your business phone field and use below script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
var phone = newValue.trim();
var validBusinessFormat = /^\+63\s2\s8866\s\d{4}$/;
if (!validBusinessFormat.test(phone)) {
g_form.showFieldMsg('phone', 'Invalid business phone format. Expected format: +63 2 8866 XXXX', 'error');
} else {
g_form.hideFieldMsg('phone', true);
}
}
If you found this helpful, please hit the thumbs-up button and mark as correct. That helps others find their solutions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2025 07:31 PM
Thank you for marking my response as helpful.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2025 04:27 PM
Correct ankur, I was expecting to use a field to input all business phone of every country and then compare it using onchange if its match then its a valid phone number.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2025 07:31 PM
Thank you for marking my response as helpful.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader