return false is still allowing form submission
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I have a CI with a question that, when answer is 'No' the form should fail at submission with an alert or error message (I have tried both). Does anyone see why it is submitting even though I have 'return false'?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @Kirsten2,
Is the Applies to catalog view checked in the client script?
Is the value being fetched correctly? add g_form.addInfoMessage after getValue line to check the value.
Is the alert popping up? If not then the condition isnt being validated.
Please Accept this response as Solution if it assisted you with your question & Mark this response as Helpful.
Kind Regards,
Ehab Pilloor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Yes, catalog view is checked. The condition is not being validated and I can't figure out why.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @Kirsten2
Could you try this code once?
function onSubmit() {
var answer = g_form.getValue('has_this_request_been_submitted_via_XXXX_s_ai_intake_process');
if (answer) {
answer = answer.toString().trim().toLowerCase();
}
if (answer == 'no' || answer == 'false' || answer == '0') {
g_form.addInfoMessage('If this request has new or changes to AI functionality and you have not submitted an AI Intake form, you cannot continue with this submission');
return false;
}
return true;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Thank you. It still is not working. I cannot figure out why my condition is not getting validated.