- 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 12:22 AM
Hello Santhoshi,
To validate IP address in catalog item you need to create catalog onchange client script which will validate your ip address format.
You can use regular expression to validate the IP address format.
var ans = g_form.getValue('fieldname');
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.setValue('fieldname');
}
Alernative solution:
Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade
Abhishek Gardade
- 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 03:37 AM
Thanks for your help!!!!
Its perfectly working now :))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2023 07:31 AM
thank you so much @Santoshi Parit this worked for me as well 🙂