- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2018 07:24 AM
Hi
I have to validate IP address and format should be like this 123.23.23.34
how can I validate it by using RegEx.
Thanks
Saurabh
Solved! Go to Solution.
- Labels:
-
Personal Developer Instance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2018 08:50 AM
Hi Saurabh,
Following you can use and it works.
function validateIP(ip) {
//Check Format
var ip = ip.split(".");
if (ip.length != 4) {
return false;
}
//Check Numbers
for (var c = 0; c < 4; c++) {
//Perform Test
if ( ip[c] <= -1 || ip[c] > 255 ||
isNaN(parseFloat(ip[c])) ||
!isFinite(ip[c]) ||
ip[c].indexOf(" ") !== -1 ) {
return false;
}
}
return true;
}
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2018 09:50 PM
Hi Saurabh,
Any update on this?
Can you mark my answer as correct, helpful if you were able to achieve the requirement. This helps in removing this question from unanswered list and helps users to learn from your thread. Thanks in advance.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2020 02:27 AM
Hi
Please check below article:
https://glidecenter.com/ip-validation-using-client-script-in-servicenow/
Thanks,
Pritam