Search code examples
javascriptformswebformsadobebusiness-catalyst

Submit field without completing "hidden" mandatory fields unless they are selected


I have a Member Registration Form where by Payment Details are required ONLY when a certain selection is made.

If I am a Member and just wanting to register myself, it won't cost me anything so no payment is required. In this instance, I want to be able to submit the form without completing the Payment Details as they are hidden from me any way using some javascript I had someone help me with.

If however, I want to bring a guest or two with me, I can select Member + XX Guests. Only when additional guests are selected do I want the Payment Options to appear and be processed.

You can see the page I am working on here: http://www.faa.net.au/test/femmes-member-form.html

Any idea how I can do this? Any help is appreciated.

This is using Adobe Business Catalyst, even though I have tagged those words, just in case it wasnt clear. THANKS.


Solution

  • Your validation is being done in this function of the HTML:

    function checkWholeForm65983(theForm) {
    var why = "";
    if (theForm.FirstName) why += isEmpty(theForm.FirstName.value, "First Name");
    if (theForm.LastName) why += isEmpty(theForm.LastName.value, "Last Name");
    if (theForm.EmailAddress) why += checkEmail(theForm.EmailAddress.value);
    if (theForm.HomePhone) why += isEmpty(theForm.HomePhone.value, "Home Phone Number");
    if (theForm.CaptchaV2) why += captchaIsInvalid(theForm, "Enter Word Verification in box below", "Please enter the correct Word Verification as seen in the image");
    if (theForm.CAT_Custom_257593) why += isEmpty(theForm.CAT_Custom_257593.value, "Member Number");
    if (theForm.CAT_Custom_255275) why += checkDropdown(theForm.CAT_Custom_255275.value, "Available Dates");
    if (theForm.CAT_Custom_255276 ) why += checkDropdown(theForm.CAT_Custom_255276.value, "Number of Tickets");
    if (theForm.CAT_Custom_255277) why += checkSelected(theForm.CAT_Custom_255277, "Payment Method");
    if (theForm.CAT_Custom_255279) why += isEmpty(theForm.CAT_Custom_255279.value, "Questions / Message or Other Information");
    if (why != "") {
        alert(why);
        return false;
    }
    if (submitcount65983 == 0) {
        submitcount65983++;
        theForm.submit();
        return false;
    } else {
        alert("Form submission is in progress.");
        return false;
    }
    }
    

    Specifically CAT_Custom_255277 is what is double checking that Payment Options are being filled. We want to ignore this check if Member = $0 is selected though. So try something like this:

    if (theForm.CAT_Custom_255277 && theForm.CAT_Custom_255276.value != "1") 
        why += checkSelected(theForm.CAT_Custom_255277, "Payment Method");
    

    The reason we set it to "1" is because your option for Member = $0 is set to "1":

    <option value="1">Member = $0</option>
    

    Hope this works!