Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Ip address validation

lucky24
Tera Contributor

Hi Team,

 

we have ip address variable on catalog item.

I want add some validation like below.

10.05.07.20

10.08.10.20/24

 

after / - should be max 2 digits.

If there are more then 2 digit, user can't able to submit form.

How can I achieve this ?

please help me here.

1 REPLY 1

Harsh_Deep
Giga Sage
Giga Sage

Hello @lucky24 

 

Please create on Change Client script on that variable and write this code.

 

var ipAddress = g_form.getValue('variable_name');
  var ipPattern = /^(\d{1,2}\.\d{1,2}\.\d{1,2}\.\d{1,2})(\/\d{1,2})?$/;
  if (!ipPattern.test(ipAddress)) {
    g_form.clearValue('variable_name');
  }

 

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.