return false is still allowing form submission

Kirsten2
Tera Contributor

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'?

 

function onSubmit() {
    // Replace 'your_question_name' with the actual internal name of your catalog variable
    var answer = g_form.getValue('has_this_request_been_submitted_via_XXXX_s_ai_intake_process');

    // Check if the answer is 'no' (adjust 'no' to match your variable's actual backend value, e.g., 'false', 'No', or '0')
    if (answer == 'No') {
        // Display alert message to the user
       
       alert('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 to halt the form submission
        return false;
    }

}
 
Thanks!
0 REPLIES 0