- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2019 12:12 AM
Hi All,
I am new in this enviornment,
My requirement is : I have one field name :IP address this can accept only this type of format XXX.XXX.XXX.XXX(12 Digit and 3 dots ).
I have tried to use the pattern in client script,Unable to understand how its work.
Many thanks in advance.
Solved! Go to Solution.
- Labels:
-
Request Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2019 03:36 AM
Its working, Need to do few changes to get eaxct result , i have done some changes in this script
need to add ^ and $ to avoid starting and end point characters(ex:...12.12.12.12....)
g_form.clearValue('ip_address',''); :to clear the
Client script:
\\
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ans = g_form.getValue('ip_address');
var reg = /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/;
if(!reg.test(ans))
{
alert('Please enter correct IP Address');
g_form.clearValue('ip_address','');
// g_form.setValue('ip_address');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2019 01:07 AM
Hi Santoshi,
use below script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
g_form.hideFieldMsg('varaibleName','true');
var ips = g_form.getValue('varaibleName');
var ips_split = ips.split(',');
for (var n = 0; n < ips_split.length; n++) {
var ips_info=ips_split[n].replace(/\s/g,'');
if (!isIP(ips_info)){
g_form.showFieldMsg('varaibleName','List contains an invalid IP address', 'error',false);
}
}
function isIP(ip)
{
if (/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(ip))
{
return(true);
}
return(false);
}
}
Thanks,
Vishal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2019 03:26 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2019 03:27 AM
In this Screenshot if you can see the variable editor :
variable IP address is filled incorrectly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2020 01:21 AM
If the IP Address is of the form - 0-255.0-255.0-255.0-255, then
Client Script:-
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ans = g_form.getValue('virtual_ip');
var reg = /^(?=\d+\.\d+\.\d+\.\d+$)(?:(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])\.?){4}$/;
if (!reg.test(ans)) {
alert('Please enter correct IP Address');
g_form.clearValue('virtual_ip', '');
// g_form.setValue('virtual_ip');
}
}
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks.
Tushar