Skip to content
Grav 2.0 is officially stable. Read the announcement →
General

Anti bot in the contact form

Solved by cvgrenoble View solution

Started by cvgrenoble 5 years ago · 7 replies · 759 views
5 years ago

Hello !

I'm a beginner in grav cms and no native english (sorry for mistake).

In the contact form, i put an empty field and i like any message bot that fill thit field to go into trash (or something like). I already add in the frontmatter:

YAML
anti-bot:
  label: anti-bot
  placeholder: 'veuillez laissez ce champ vide'
  type: email
  validate:
    required: false

but it is not enought.

Can you help me ?
ps : I don't want to use captcha

last edited 07/15/21 by pamtbaau
5 years ago

i change:

type: email

by

type: honeypot

this is enought?

5 years ago

@cvgrenoble, Have you tried it?

5 years ago

The anti-bot field don't appear, seem to be how the honeypot work. But I don't know if a bot will go in the trap.

5 years ago

using the example in grav form field index make the field appear and send the mail

YAML
fields:
    honeypot:
      type: honeypot
👍 1
5 years ago

@cvgrenoble, I'm afraid there is misunderstanding on the concept of a honeypot field...

A honeypot is an <input> field which is invisible/hidden to a regular user. Most bots however don't "look" at the displayed webpage, but instead interpret the generated HTML/DOM and search for <input> fields. If the bot then enters data in the honeypot field, the server will treat the posted form as spam.

👍 1
5 years ago

I already understand how the honeypot work like you describe it 🙂
but the example giving by grav form field index that I put just before don't work (the field appear and if I fill it the mail is send).
The field don't appear if I put:

YAML
anti-bot:
  label: Message
  placeholder: Entrez votre message’
  type: honeypot
  validate:
    required: false
👍 1
last edited 07/15/21 by cvgrenoble
5 years ago Solution

I remove the

TXT
fields:

in the

YAML
fields:
    honeypot:
      type: honeypot

that i use i example.
Now it's look like this:

YAML
title: Contact
form:
    name: contact
    fields:
        name:
            label: Name
            placeholder: 'Entrez votre nom'
            autocomplete: 'on'
            type: text
            validate:
                required: true
        email:
            label: Email
            placeholder: 'Entrez votre adresse mail'
            type: email
            validate:
                required: true
        message:
            label: Message
            placeholder: 'Entrez votre message'
            type: textarea
            validate:
                required: true
        honeypot:
            type: honeypot

and it seem to be OK.

👍 1

Suggested topics

Topic Participants Replies Views Activity
General · by Hanns Mattes, 11 hours ago
1 14 3 hours ago
General · by Andy Miller, 3 hours ago
0 8 3 hours ago
General · by Jerry Hunt, 5 days ago
2 136 1 day ago
General · by pamtbaau, 2 days ago
1 93 2 days ago
General · by Andy Miller, 2 days ago
0 78 2 days ago