- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2020 07:20 AM
Hi all,
I have a Validation regex for a field within a catalogue item.
It currently does not allow the characters [^"();:<>]+ which works fine.
But now I need to prevent spaces being entered at the beginning, middle or end, how can I do this?
Can I add some characters to the current regular expressions field?
I
Thanks in advance,
Usmaan.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2020 06:19 AM
Hi,
Above provided solution is also from Orlando.
To approach ServiceNow,
Create HI ticket.
https://hi.service-now.com/hisp
If it is ok for you can you share the PDI details on dhananjay.pawar1111@gmail.com I will check.
If possible share
Catalog item name and access details.
Thanks,
Dhananjay.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2020 02:55 AM
You can also have onChange catalog client script on that variable.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var val=g_form.getValue('account_no'); // enter correct variable name here
var pattern=/^[a-zA-Z0-9_-]*$/;
if(val.search(pattern)==-1)
{
alert("Incorrect value, please enter correct one");
g_form.setValue('account_no',''); // enter correct variable name here
}
else{
alert("correct value");
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2020 03:11 AM
onchange client script would be last option, but would prefer variablle validation regex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2020 03:10 AM
used this and same outcome. It does not throw error when leading or trailing spaces are entered, only spaces inbetween text are throwing error

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2020 03:23 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2020 03:30 AM
you also have space between the numbers, remove the space inbetween and then try trailing and leading spaces?