We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5532
    • 251 Posts
    Hi There,

    We have an email subscription form that goes to Campaign Monitor.

    What would be the best way to validate some of the fields? The form from Campaign Monitor doesn’t validate the mailing list checkboxes so it’s possible someone can submit the form without choosing a subscription list.

    Is there a way to have Modx validate a form before it is sent to Campaign Monitor - or is Java the best way to do this?

    Cheers
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Javascript is good, being more user-friendly, but back-end validation is important as well. The eForm snippet validates fields, and is very flexible. It uses an interesting event model to allow custom processing at several points in the form generation and processing.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 5532
        • 251 Posts
        Thanks Susan - it looks a bit complex for me, not sure where to start...

        I’ll work through the wiki article and am pretty sure I’ll be able to work something out but how would things be structured to work in this situation?

        - Recreate the Campaign Monitor form using eFrom
        - Use eFrom to validate the script
        - Use eFrom to send the from to Campaign Monitor

        Just not entirely sure how communication with Campaign Monitor would work - would eForm just pass the form as it does from the page currently?

        Cheers

        Ben
          • 5532
          • 251 Posts
          At this point all I need is to have eFrom ensure one of two check boxes is selected - is this simple or would I have to learn everything to achieve this?

          Also, the wiki states eFrom is for converting forms into emails. Because I’m not sending an email will eFrom work in this instance?

          Cheers
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            Second question is easiest... there’s a parameter to not send emails &noemail=`1`

            Not sure how requirement works for check boxes; will look it up and get back to you. I should know this anyway!

            Ok, radio buttons work like this; I presume that check boxes (also have the same "name" attribute) would work the same way:
                        <input type="radio" name="format" value="legal" eform="Return Format::1" > Legal
                        <input type="radio" name="format" value="formal"> Formal
                        <input type="radio" name="format" value="loose" checked="checked""> Informal
            

            The trick is to have the first one include the eform attribute (this gets removed during processing so the form will validate):
            <input... ... eform="Field Name:data type(left blank for this):1=required/0=not required"

              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org