- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2020 07:51 AM
Hi All,
I have created a single line variable field for catalog item. Now i want to validate the url. Kindly help on this how to achieve this. Thanks in advance
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2020 12:16 PM
Hi,
I have modified the script of willem slightly to exclude www. Check this.
var url=newValue;
var re = /^(http[s]?:\/\/){0,1}(www\.){0,1}[a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,5}[\.]{0,1}/;
if(url.indexOf("www.") > -1 || !re.test(url)) {
g_form.showFieldMsg('your field', 'invalid url');
return false;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2020 12:04 PM
www also should not be accepted. Please help on this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2020 12:09 PM
Can you share the formats that should be accepted?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2020 03:42 AM
http and https are the accepted format
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2020 03:45 AM
Ok, then you can try the script I provided.
var url = newValue;
var re = /^(http[s]?:\/\/){0,1}[a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,5}[\.]{0,1}/;
if (url.indexOf("www.") > -1 || !re.test(url)) {
g_form.showFieldMsg('your field', 'invalid url');
return false;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2020 04:38 AM
Hi
Did you mark another answer as Correct by accident? I provided you with the complete regex and how to use it...
If it was by accident, can you please correct it.
If not, consider marking some answers as helpful to reward effort and time put in.