&validate=`workemail:blank` is not behaving properly

117 views Asked by At

I've tried using this example to prevent my page from getting spam on it, but when I test it out and put text in the field, my submit button is still sending the form out. I use formit for my websites.

The idea is to create a hidden field and if a spambot inserts something into that hidden field, then no email is sent out.

Example in question

https://docs.modx.com/extras/revo/formit/formit.tutorials-and-examples/formit.using-a-blank-nospam-field

Snippets of the code

<input type="hidden" name="workemail" value="" />
[[!FormIt? &validate=`workemail:blank`]]

I'm using the exact code from there, and the code below is my field - I've made sure the field is within the tags.

<input type="hidden" name="workemail" value="[[!+fi.workemail]]" />

my formit code looks like

[[!Formit?
        &hooks=`spam,FormItSaveForm,email,redirect`
        &redirectTo=`122`
        &formName=`Contact Form`
        &formFields=`fname,title,company,email,options,subject,message`
        &emailTpl=`fi-contact_email`
        &emailSubject=`[[*contact_email_subject]]`
        &emailTo=`[[*contact_email_to_address]],[email protected]`
        &emailFrom=`[[*contact_email_from_address]]`
        &emailFromName=`[[*contact_email_from_name]]`
        &emailReplyTo=`[[+email]]`
        &submitVar=`contactform`
        &validate=`workemail:blank,
        fname:required,
        email:email:required,
        message:stripTags,
        username:blank`
      ]]

Any help is appreciated, thank you!

1

There are 1 answers

0
curveball On

Maybe something of the following will work out:

0) First of all, update MODX and FormIt extra and try again.

1) If the problem persists, try to remove [[!+fi.workemail]] from the value attribute.

<input type="hidden" name="workemail" value="" />

2) If the previous step didn't help, add another field to your form. So, it should be:

<input type="hidden" name="workemail" value="" />
<input type="hidden" name="nospam:blank" value="" />

3) Also try to remove workemail stuff from both the markup and formit call and instead add

<input type="hidden" name="nospam:blank" value="[[+fi.nospam]]" />

Alternatively, take a look at other options like ReCaptchaV2