We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40473
    • 6 Posts
    I'm having difficulty getting the #FUNCTION feature to work properly when validating eForm fields. I simply want to ensure that if the user checks the "Other" radio button that they input something into the "Other Description" field. I have verified that the eForm is working properly and the function PHP is being called when the form is submitted. eForm is displaying the validation message following submission.

    It seems like this should be super easy but I just can't seem to get it working. I suspect the issue is my poor PHP coding skills so please have pity on this nube. Your assistance would be appreciated. I've poured thru the forums with no luck. Thank you!

    Here's the eForm call from the page resource:

    [!eForm_functions!]
    [!eForm? &formid=`FormV2-test` &to=`[email protected]` &from=[+email+] &fromname=[+name+] &tpl=`FormV2-test` &report=`FormReportV2-test` &thankyou=`FormThanks` &vericode=`1` &subject=`Form Submission: [+name+]` &protectSubmit=`1` &automessage=`FormAutoResponse` &autosender=`[email protected]` &autoSenderName=`--Sender Name--` !]

    The "FormV2-test" Chunk:

    Which of the following best describes your organization?

    <input type="radio" value="Tax-Exempt" name="OrgType" eform="Organization Type::1"> Tax-Exempt Organization

    <input type="radio" value="Government" name="OrgType" eform="Organization Type::1"> Government Agency

    <input type="radio" value="For-Profit" name="OrgType" eform="Organization Type::1"> For-Profit Business or Corporation

    <input type="radio" value="Other" name="OrgType" eform="Organization Type::1::#FUNCTION checkDesc"> Other

    Please Explain: <input style="width:400px" name="OrgTypeOtherDesc" type="text" eform="Other Description:string:0" />

    The eForm_Functions Snippet:

    <?php
    // Verify that the user entered a description if they checked 'Other' for OrgType
    function checkDesc(&$fields,&$vMsg,&$rMsg) {
    if($fields['OrgType'] == 'Other')&&($fields['OrgTypeOtherDesc'] == ''){
    $rMsg['OrgTypeOtherDesc'] = "You're missing the description!";
    return false;
    }
    return true;
    }
    ?>