IP address validation
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2023 09:08 PM
Hi Team,
I have to validate IP address.
IP address should be range from 0 to 255 and should be Like 165.237.245.224.
How can I achieve above asking?
Thanks
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2023 09:32 PM
I have created blog for this. have a look
IP Address Validation Client Side
If my response helped please mark it correct and close the thread so that it benefits future readers.
Regards,
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2023 11:18 PM
Hi @lucky24
OOTB there's existing Field Type and Variable Type for IP Address (Validated IPV4, IPV6).
Ref: IP address field type
If you're working with Catalog Variables, you can define your own Validation Regex in the Question Regular Expressions [question_regex].
You can also create a Client Script to validate it.
Sample
var regex = /^([0-9]{3})+([-]{1})+((0-9)]{2})+([-]{1})+([0-9]{4})$/; //Replace your regex validation
if (!regex.test(newValue)) {
g_form.clearValue('<your_field_name>');
g_form.showFieldMsg('<your_field_name>', 'Not a valid IP Address ', 'error', true);
}
Cheers,
Tai Vu