- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2024 11:20 PM
On using a variable check box via a variable set, 3 checkbox are there, if none of the check box are selected user should not be able to submit the request and alert message should be there on top.
I was able to sort the alert part but it seems now it is not allowing to raise a request even if I select all check boxes or any.
function onSubmit() {
if
(g_form.getValue('checkbox_1) != '') || ('checkbox_2) != '') || (checkbox_3) != '')) {
alert("Please select at least one option to submit request");
return false;
}
else{
return true;
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2024 11:36 PM
Hello Ankit,
Please use below script
function onSubmit() {
//Type appropriate comment here, and begin script below
if(g_form.getValue('checkbox1') == 'false' && g_form.getValue('checkbox2') == 'false' && g_form.getValue('checkbox3') == 'false') {
alert("Please select at least one option to submit request");
return false;
}
else{
return true;
}
}
Since they are checkboxes they will always give true or false as an answer.
Also we only want to restrict submission if none of them are checked. So instead of using "or" condition you need to use the "and" condition.
This will allow submission even if 1 checkbox is ticked as the condition won't be satisfied.
If my answer helps you in any way please mark it as correct or helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2024 11:36 PM
Hello Ankit,
Please use below script
function onSubmit() {
//Type appropriate comment here, and begin script below
if(g_form.getValue('checkbox1') == 'false' && g_form.getValue('checkbox2') == 'false' && g_form.getValue('checkbox3') == 'false') {
alert("Please select at least one option to submit request");
return false;
}
else{
return true;
}
}
Since they are checkboxes they will always give true or false as an answer.
Also we only want to restrict submission if none of them are checked. So instead of using "or" condition you need to use the "and" condition.
This will allow submission even if 1 checkbox is ticked as the condition won't be satisfied.
If my answer helps you in any way please mark it as correct or helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2024 12:33 AM
Thanks Vishwa, much appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2024 12:45 AM - edited 04-18-2024 10:24 PM
Hi @Ankit Raj ,
Please make use of below script:
function onSubmit() {
var checkbox_1 = g_form.getValue('checkbox_1');
var checkbox_2 = g_form.getValue('checkbox_2');
var checkbox_3 = g_form.getValue('checkbox_3');
if((checkbox_1 == 'false') && (checkbox_2 == 'false') && (checkbox_3 == 'false')) {
alert("Please select at least one option to submit request");
return false;
}
else{
return true;
}
}
Please mark my answer helpful and accept as a solution if it helped 👍✔️
Kavita Bhojane
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2024 01:25 AM
Hi @Ankit Raj
Create a Onsubmit catalog client script in the variable set were you have the 3 check boxes. Use the below script.
function onSubmit() {
if(g_form.getValue('checkbox_var1') == 'false' && g_form.getValue('checkbox_var2') == 'false' && g_form.getValue('checkbox_var3') == 'false')
{
alert("your alert message here........................");
return false;
}
else
{
return true;
}
}
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....