- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2016 08:48 AM
When an user selects 'No' for a particular variable, an alert box should be displayed and also they should not be able to submit the form. I need to write a client script for this.
Can you assist me in achieving this?
Best,
Akshitha
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2016 08:51 AM
Hi,
You can use an onSubmit client script to do this validation.
Here is a small example (UNTESTED)!
function onSubmit() {
if (g_form.getValue('your_variable') == 'No') {
alert('Invalid answer');
return false;
}
}
Reference: Client Scripts - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2020 01:27 PM
this works great when you select "Try It" from the catalog item in the platform; However, it appears to be ignored when running from the portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-24-2020 07:09 AM
Select UI Type both in the Client script.
hope this helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-24-2020 07:10 AM
select the UI Type is both.
Hope this helps