We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5727
    • 160 Posts
    Hello everyone,

    I’m trying to build a form with a text field that must stay empty for the form validation to pass. It’s a simple spam bot prevention mechanism, I just hide the field with CSS and it stops the majority of the spam bots.

    I haven’t been able to tell eForm to do that. I tried this config for the field:
    eform="Bot Death:string:0:#EVAL empty($value)"

    Now I just read that #EVAL is depecrated, so I’m wondering if anyone knows what would be the proper way to handle this?
      Olivier Deland
      Montreal, Canada - Web Developer
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      I use an eForm event, eformOnValidate. I have this snippet checkField
      <?php
      function checkField(&$fields,&$vMsg,&$rMsg) {
          if(!empty($fields['Last__Name'])) {
              return false;
          } else {
          return true;
          }
      }
      ?>

      and this eForm snippet call
      [!checkField!]
      [!eForm? &formid=`ContactForm` &tpl=`ContactForm` &report=`ContactReport` &subject=`sottwell.com Contact` &thankyou=`ThankYou` &replyto=`email` &debug=`1` &eformOnBeforeMailSent=`getServer` &eformOnValidate=`checkField`!]
      

      and this in my chunk tpl for the form
      <input type="text" name="Last__Name" id="LastName" size=30 autocomplete="off" eform="LastName::0" />
        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
        • 5727
        • 160 Posts
        Working perfectly!

        Thank you so much for this Ma’am!
          Olivier Deland
          Montreal, Canada - Web Developer