onChange Validation Script against Catalog Item Variable - HELP!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2013 12:48 AM
Hi there,
I'm fairly new at using ServiceNow and I have a little bit of experience with JavaScript but I'm shaky with the ServiceNow API.
I am trying to put together a Service Catalog client script that validates on a variable (single line text field) so that users are only able to input numeric characters in this particular input.
I've tried a number of different scripts but I've not had much luck - after speaking to someone at ServiceNow they suggested that I look at some of the Validation Scripts in ServiceNow (System Definition > Validation Scripts). I had a look at the numeric script and tried this in my Service Catalog client script but it didn't work. After reviewing the code and carrying out some more research I can see that these scripts aren't using the GlideForm API and I believe this is where it is going wrong.
Has anybody else used Service Catalog Client Scripts to cover a similar scenario and if so please can you shine some light as to how you did it?
Many thanks 🙂
Jamie

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-26-2015 01:41 PM
Yeah, this is what I ended up doing:
function onChange(control, oldValue, newValue, isLoading)
{
if (newValue.match(/\D+/))
g_form.setValue('variables.port_number', '');
}