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 ,
First, check whether the script is entering the if condition. Add an alert inside the condition before return false to verify this.
function onSubmit() {
var answer = g_form.getValue(
'has_this_request_been_submitted_via_XXXX_s_ai_intake_process'
);
if (answer == 'No') {
alert('Inside No condition. Answer: ' + answer);
return false;
}
}
If the alert does not appear, g_form.getValue() may be returning a different value, such as NO , false , or 0 , instead of No. Jsut Confirm it with alret or log and then use in if condtion.
Check the actual value and update the condition accordingly. Once you confirm the condition is working, you can add the error message and keep return false to prevent submission.
Regards,
Tejas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Thank you. I have verified the value is 'No', but it is still ignoring my if statement and submitting.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
it means it's unable to compare the value
are you comparing correct value of No OR no?
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Thank you. I have verified the value is 'No', but it is still ignoring my if statement and submitting.