- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2020 01:38 AM
Hi All,
We have two choice variable if user not selected any of them it show trigger a alert message and prevent for submission.
user should not able to submit without selecting those choice variable.
Thanks,
Varma
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2020 02:02 AM
Then you can check and abort only if both are empty, like so:
function onSubmit() {
if (g_form.getValue('your variable1') == '' && g_form.getValue('your variable2') == '') {
g_form.addErrorMessage('Fields can not be empty');
return false;
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2020 01:42 AM
Hi,
In your onSubmit() client script you can check for values & if it is empty then you need to use return false; to abort the action.
For eg.
function onSubmit()
{
if(g_form.getValue('field1')=='') //missed an extra roundbracket
{
return false;//abort action
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2020 01:42 AM
Hi Varma,
Please try like this:
Replace your variable1 and 2 with your variable name
function onSubmit() {
if (g_form.getValue('your variable1') == '' || g_form.getValue('your variable2') == '') {
g_form.addErrorMessage('Fields can not be empty');
return false;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2020 01:59 AM
Hi Willem, Thanks for reply
What if user need to select any one of the variable like variable1 or varible2.
Thanks,
Varma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2020 02:02 AM
Then you can check and abort only if both are empty, like so:
function onSubmit() {
if (g_form.getValue('your variable1') == '' && g_form.getValue('your variable2') == '') {
g_form.addErrorMessage('Fields can not be empty');
return false;
}
}