# Conditional logic: compare field values to prevent spam

**URL:** <https://community.gravityforms.com/t/conditional-logic-compare-field-values-to-prevent-spam/17326>\
**Category:** Get Help\
**Tags:** conditional-logic, gform\_field\_validation, spam, gform\_validation, gform\_entry\_is\_spam\
**Created:** [April 23, 2024, 12:04pm UTC](https://community.gravityforms.com/t/conditional-logic-compare-field-values-to-prevent-spam/17326 "2024-04-23T12:04:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andre\_B](https://avatars.discourse-cdn.com/v4/letter/a/ecd19e/32.png) [@Andre\_B](https://community.gravityforms.com/u/Andre_B)\
**Post date:** [April 23, 2024, 12:04pm UTC](https://community.gravityforms.com/t/conditional-logic-compare-field-values-to-prevent-spam/17326/1 "2024-04-23T12:04:53Z")

</div>

One of my sites apparently caught the attention of spammers. I have a contact form that gets used by them multiple times every day.  
I already use conditional logic to show/hide the submit button depending on the result of a simple math question. That doesn’t stop theses spammers.

I noticed that all of these spam mails have in common that the fields ‘first name’ and ‘last name’ have the exact same content. So comparing the content of these 2 fields in a conditional logic would be helpful to resolve the problem. However this is not an available option in GF. In conditional logic I can only show/hide fields based on specific values, not dynamic ones. In other words there’s no option to compare these 2 fields.

Can anyone offer helpful advice?

---

<div class="post-metadata">

**Author:** ![Andre\_B](https://avatars.discourse-cdn.com/v4/letter/a/ecd19e/32.png) [@Andre\_B](https://community.gravityforms.com/u/Andre_B)\
**Post date:** [April 23, 2024, 12:22pm UTC](https://community.gravityforms.com/t/conditional-logic-compare-field-values-to-prevent-spam/17326/2 "2024-04-23T12:22:46Z")

</div>

One more detail. All of these spam messages contain a URL in the message field. Is there a way to use this for spam prevention?

---

<div class="post-metadata">

**Author:** ![uamv](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/uamv/32/1412_2.png) [@uamv](https://community.gravityforms.com/u/uamv)\
**Post date:** [April 26, 2024, 1:10pm UTC](https://community.gravityforms.com/t/conditional-logic-compare-field-values-to-prevent-spam/17326/3 "2024-04-26T13:10:11Z")

</div>

You could use one of the following hooks to check the values upon submission and intercept in some way:

[gform\_validation](https://docs.gravityforms.com/gform_validation/)  
[gform\_field\_validation](https://docs.gravityforms.com/gform_field_validation/)  
[gform\_entry\_is\_spam](https://docs.gravityforms.com/gform_entry_is_spam/)  
[gform\_abort\_submission\_with\_confirmation](https://docs.gravityforms.com/gform_abort_submission_with_confirmation/)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/gravityforms1/original/2X/f/fef63f0599c45e0218c30d9f5d7ca8bff9b00189.png) [@system](https://community.gravityforms.com/u/system)\
**Post date:** [May 26, 2024, 1:10pm UTC](https://community.gravityforms.com/t/conditional-logic-compare-field-values-to-prevent-spam/17326/4 "2024-05-26T13:10:43Z")

</div>

Closed on May 26, 2024, 1:10pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
