Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2024 02:28 PM
Hi, I have a form that needs to produce an error when a checkbox is not checked, I got that to function. I need it to only operate if another yes/no variable is answered yes, this is where i'm stuck. thank you
function onSubmit() {
// Check if the checkbox 'cl_ctx_app' is not checked (assuming 'false' means not checked)
if (g_form.getValue('cl_ctx_app') == 'false') {
// If not checked, show an error message next to the checkbox field
g_form.showFieldMsg('cl_ctx_app', 'You must check the CTX APP Access checkbox', 'error');
// Return false to prevent form submission
return false;
}
// If the checkbox is checked (value is not 'false'), the form submission will proceed
}
Solved! Go to Solution.
1 ACCEPTED SOLUTION
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2024 02:38 PM
Hi @Bradley Bush ,
Please see script below
function onSubmit() {
// Check if the other Yes/No variable is answered "Yes", change the variable name to match yours
if (g_form.getValue('other') == 'Yes') {
// If 'other_variable' is "Yes", proceed to check 'cl_ctx_app' checkbox
if (g_form.getValue('cl_ctx_app') == 'false') {
// If 'cl_ctx_app' checkbox is not checked, show an error message
g_form.showFieldMsg('cl_ctx_app', 'You must check the CTX APP Access checkbox', 'error');
// Return false to prevent form submission
return false;
}
}
// If 'other_variable' is not "Yes" or 'cl_ctx_app' is checked, the form submission will proceed
}
If my response helped you, please click on "Accept as solution" and mark it as helpful.
- Saloni
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2024 02:38 PM
Hi @Bradley Bush ,
Please see script below
function onSubmit() {
// Check if the other Yes/No variable is answered "Yes", change the variable name to match yours
if (g_form.getValue('other') == 'Yes') {
// If 'other_variable' is "Yes", proceed to check 'cl_ctx_app' checkbox
if (g_form.getValue('cl_ctx_app') == 'false') {
// If 'cl_ctx_app' checkbox is not checked, show an error message
g_form.showFieldMsg('cl_ctx_app', 'You must check the CTX APP Access checkbox', 'error');
// Return false to prevent form submission
return false;
}
}
// If 'other_variable' is not "Yes" or 'cl_ctx_app' is checked, the form submission will proceed
}
If my response helped you, please click on "Accept as solution" and mark it as helpful.
- Saloni
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2024 02:47 PM
thank you so much just what i needed:)