Validation on catalog variable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2024 03:36 AM
Hi team,
I have requirement like '-' is mandatory in one of my variable called "Ticket id' similar to the format like 0000-000 written onchange script but its working for false condition when am giving the favorable condition its still showing as error below is my script.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var re = /^[a-zA-Z]+-[a-zA-Z0-9]+$/;
var ID= g_form.getValue('Ticket_id');
if (!re.test(ID)) {
g_form.showErrorBox('Ticket_id', ID+ " is not a Ticket ID. Valid Ticket ID should follow 1234-100 format", 'error');
}
}
6 REPLIES 6
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2024 04:12 AM
Hi @Vishal Birajdar Thanks for it but how can we throw an error if it is not a valid one here.
Could you please help me with the script here
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2024 04:37 AM
Hi @raj99918
You can put message in regex itself see below highlighted
Vishal Birajdar
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates