Counting ',' from a field and not allowing more than 29 ','
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2024 12:59 AM
Hi All,
I have a IP address validation request, where only 30 ',' comma separated IP address should be allowed.
I have written a client script for IP validation, can this ',' validation/ allowing only 30 Ip address can be done through client script? if yes, please help. Else suggest some feasible solution.
Client script -
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ipAddresses = g_form.getValue('enter_ip_addresses');
var ipList = ipAddresses.split(',');
var ipRegex = /^(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]?)$/;
for (var i = 0; i < ipList.length; i++) {
var ip = ipList[i];
if (!ipRegex.test(ip)) {
g_form.clearValue('enter_ip_addresses');
g_form.triggerErrorChangeFieldSet('Invalid IP', 'enter_ip_addresses');
} else {
g_form.addinfoMessage('valid ip', 'enter_ip_addresses');
}
}
}
0 REPLIES 0