FormIt.Using a Blank NoSpam Field
Last updated Nov 28th, 2019 | Page history | Improve this page | Report an issue
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$301 per month—let's make that $500!
Learn moreUsing a Blank No-Spam Field¶
Often, spambots fill every form field to pass validation. Thus, a good way to prevent spam is to add a field in your form and require it to be blank for submission to succeed.
FormIt provides you with the "blank" validator, which can be used to achieve a "nospam" field.
Setup¶
Simply add the following input into your form. You can change the name of the field at any time; using commonly used field names like "workemail" can be used to trick spambots into filling in the field:
<input type="hidden" name="workemail" value="" />
Then, in your FormIt call, add the blank validation:
[[!FormIt? &validate=`workemail:blank`]]
If you wish to provide an error message to be displayed, you can do so in the normal FormIt syntax (this example would be [[+fi.error.workemail]]
).
Make sure not to use an existing field name in your form for the nospam field! This will prevent FormIt from processing your form.
See Also¶
- FormIt.Examples.Custom Hook
- FormIt.Examples.Simple Contact Page
- FormIt.Handling Selects, Checkboxes and Radios
- FormIt.Using a Blank NoSpam Field
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$301 per month—let's make that $500!
Learn more