Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

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

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.