Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      The Value-Driven AI Roadmap

      September 9, 2025

      This week in AI updates: Mistral’s new Le Chat features, ChatGPT updates, and more (September 5, 2025)

      September 6, 2025

      Designing For TV: Principles, Patterns And Practical Guidance (Part 2)

      September 5, 2025

      Neo4j introduces new graph architecture that allows operational and analytics workloads to be run together

      September 5, 2025

      ‘Job Hugging’ Trend Emerges as Workers Confront AI Uncertainty

      September 8, 2025

      Distribution Release: MocaccinoOS 25.09

      September 8, 2025

      Composition in CSS

      September 8, 2025

      DataCrunch raises €55M to boost EU AI sovereignty with green cloud infrastructure

      September 8, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Finally, safe array methods in JavaScript

      September 9, 2025
      Recent

      Finally, safe array methods in JavaScript

      September 9, 2025

      Perficient Interviewed for Forrester Report on AI’s Transformative Role in DXPs

      September 9, 2025

      Perficient’s “What If? So What?” Podcast Wins Gold Stevie® Award for Technology Podcast

      September 9, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Distribution Release: MocaccinoOS 25.09

      September 8, 2025
      Recent

      Distribution Release: MocaccinoOS 25.09

      September 8, 2025

      Speed Isn’t Everything When Buying SSDs – Here’s What Really Matters!

      September 8, 2025

      14 Themes for Beautifying Your Ghostty Terminal

      September 8, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»Honeypot Fields in Sitecore Forms

    Honeypot Fields in Sitecore Forms

    July 23, 2025

    When working with forms, a common problem is spam form submissions. There are several ways to prevent this problem. Using CAPTCHAs to stop bot submissions is the most popular technique to avoid this issue. However, bots can now bypass CAPTCHA security. This is where honeypot fields come in: a simple, invisible, and user-friendly way to detect and prevent automated submissions. In this post, we’ll explore how to effectively implement and use honeypot fields in Sitecore Forms.

     

    What Is a Honeypot Field and Why Use It in Sitecore Forms?

    A honeypot field is a hidden input field that has been implemented in forms. It is invisible to humans but detected by spambots. Bots often fill out all form fields automatically, so they unknowingly complete the hidden honeypot field, which aids in the detection and blocking of spam submissions.

    In Sitecore Forms, honeypot fields offer an easy-to-use method of blocking spam without interfering with user experience. Honeypot fields are not visible to users and don’t need any action from them, in contrast to CAPTCHAs. By using honeypots, you can keep the security of your form submissions and your Sitecore database by eliminating unnecessary entries.

     

    How to Implement Honeypot Fields in Sitecore Forms

    Step 1: Create the Honeypot Field View Model

    Since the honeypot field will be a simple input field, we start by creating a new model class HoneypotFieldViewModel.cs that inherits from StringInputViewModel.

    public class HoneypotFieldViewModel : StringInputViewModel
    {
    }

    Step 2: Create the Honeypot Validator Class

    Next, create a validator class named HoneypotValidator.cs. This class is responsible for validating that the honeypot field contains no data when the form is submitted. If the field has value, the submission should be marked as spam.

    public class HoneypotValidator : ValidationElement<string>
    {
        public HoneypotValidator(ValidationDataModel validationItem) : base(validationItem)
        {
        }
     
        public override IEnumerable<ModelClientValidationRule> ClientValidationRules
        {
            get
            {
                yield break;
            }
        }
     
        public override ValidationResult Validate(object value)
        {
            var fieldValue = value as string;
     
            if (!string.IsNullOrEmpty(fieldValue))
            {
                return new ValidationResult("Invalid submission.");
            }
     
            return ValidationResult.Success;
        }
    }

    Step 3: Create the Honeypot View

    Create a view named Honeypot.cshtml at the path Views/FormBuilder/Honeypot.cshtml. This view will render the honeypot field, which should be hidden from users but remain detectable by bots.

    @model Your.Namespace.HoneypotFieldViewModel
     
    <input id="@Html.IdFor(m => m.Value)"
       name="@Html.NameFor(m => m.Value)"
       value="@Model.Value"
       class="detailed-info"
       tabindex="-1"
       aria-hidden="true" />
     
    <script>
    if (window.location.href.includes('/sitecore/client/Applications/FormsBuilder'))
    {
    var inputElement = document.getElementById('@Html.IdFor(m => m.Value)');
            if (inputElement) {
                inputElement.outerHTML = '<span>Optional Field</span>';
            }
    }
    </script>
    

    Css to hide field:

    .detailed-info {
      opacity: 0;
      position: absolute;
      top: 0;
      left: 0;
      height: 0;
      width: 0;
      z-index: -1;
    }

    Note:

    When implementing a honeypot field to catch bots, it’s important to create the input field just like any other form input — with proper id, name, and value attributes. Avoid naming it obviously like “honeypot” or “trap,” since bots often look for such keywords to skip or bypass honeypots.

    Do not use display: none or hidden attributes to hide the field, as many bots can detect these and ignore the field. Instead, use CSS techniques that visually hide the field from human users but keep it accessible in the DOM, such as setting opacity: 0, positioning it off-screen, or shrinking it to zero size, like in our example.

    This way, normal users won’t see the field, but bots that blindly fill in all inputs will likely trigger the honeypot, helping you filter out spam submissions more effectively.

     

    Sitecore Item Setup

    Now let’s configure the necessary items in the Sitecore database.

    In the Core Database:

    • Create a form property by copying an existing item, such as SingleLineText, and rename it as “HoneypotField”:

    /sitecore/client/Applications/FormsBuilder/Components/Layouts/PropertyGridForm/PageSettings/Settings/HoneypotField

     

    Formpropertyhoneypotfield1

    In the Master Database:

    • In the Content Editor, go to the following path: /sitecore/templates/System/Forms/Fields and Create a copy of the Input field and rename it to “Honeypot”:

    /sitecore/templates/System/Forms/Fields/Honeypot

     

    Honeypottemplate1

    • Create a new Validation Item at /sitecore/system/Settings/Forms/Validations called “Honeypot Validation”.
      /sitecore/system/Settings/Forms/Validations/Honeypot Validation

     

    Honeypotvalidator1

    • Now create a new field type under path /sitecore/system/Settings/Forms/Field Types/Security and name it “Honeypot Field” :

    /sitecore/system/Settings/Forms/Field Types/Security/Honeypot Field

     

    Honeypotfieldtype1

     

    Configuration for Honeypot Field Type

    When configuring the Field Type for the Honeypot Field, set the following:

    • View Path: Path to your view file (e.g., ~/Views/FormBuilder/Honeypot/Honeypot.cshtml).
    • Model Type: <Namespace>.HoneypotFieldViewModel, <AssemblyName>.
    • Allowed Validations: Honeypot Validation.
    • Property Editor: Property Editor Settings/HoneypotField.
    • Field Template: Fields/Honeypot.
    • Icon: Choose any icon you prefer (e.g., OfficeWhite/32×32/element.png).
    • BackgroundColor: Tomato (or any color you prefer).

     

    Adding Honeypot Field to Forms

    Now Honeypot field is available for use in Sitecore Forms. Simply go to Sitecore Forms, drag and drop the Honeypot field under the Security section. Don’t forget to select the Honeypot Validation checkbox.

     

    Form1

     

    Browser Inconsistencies with Honeypot Fields

    During testing, I noticed that honeypot fields can behave inconsistently across different browsers, which is important to understand for effective development and testing:

    • When manually changing the value of hidden honeypot input fields via browser developer tools (for example, using “Edit as HTML” or direct form editing), some browsers update the visible DOM but JavaScript cannot reliably read these manual changes.

    Htmlelementhoneypotfield1

    Htmlconsolehoneypot1

    • However, setting the field’s value programmatically via JavaScript works correctly and consistently across all browsers. For example:

    document.querySelector(‘.detailed-info’).value = “test”;

    Htmlconsolejshoneypot1

    • This behaviour is related to how some browsers handle manual DOM manipulation of hidden inputs and does not impact real-world honeypot use cases, as bots typically set these values programmatically.

    Key takeaway: Always rely on programmatic methods when testing or manipulating honeypot fields to ensure consistent behaviour across browsers.

     

    Conclusion

    And that’s it! Your Honeypot field is now set up and ready to use. This will help prevent spam form submissions without requiring any action from your users.

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleMultisite Maximum Item Validation for Content Area or Link Collection in Optimizely CMS-12.
    Next Article Unboxing AG-Grid: A Quick Start Guide for Angular Developers

    Related Posts

    Development

    Leading the QA Charge: Multi-Agent Systems Redefining Automation

    September 9, 2025
    Development

    Stop Duct-Taping AI Agents Together: Meet SmythOS

    September 9, 2025
    Leave A Reply Cancel Reply

    For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

    Continue Reading

    Microsoft has a new tool to get you off Windows 10 and onto a Windows 11 PC

    Operating Systems

    CVE-2025-5228 – D-Link DI-8100 HTTPd Get Parm Stack-Based Buffer Overflow

    Common Vulnerabilities and Exposures (CVEs)

    What I Wish Someone Told Me When I Was Getting Into ARIA

    Tech & Work

    Conditional Collection Skipping with Laravel’s skipWhile Method

    Development

    Highlights

    CVE-2025-5121 – GitLab Compliance Framework Authorization Bypass

    June 20, 2025

    CVE ID : CVE-2025-5121

    Published : June 20, 2025, 6:15 p.m. | 4 hours, 29 minutes ago

    Description : An issue has been discovered in GitLab CE/EE affecting all versions from 17.11 before 17.11.4 and 18.0 before 18.0.2. A missing authorization check may have allowed compliance frameworks to be applied to projects outside the compliance framework’s group.

    Severity: 8.5 | HIGH

    Visit the link for more details, such as CVSS details, affected products, timeline, and more…

    Google’s Veo 3: The Dawn of AI-Powered Hollywood-Level Moviemaking?

    May 23, 2025

    TacticAI: an AI assistant for football tactics

    May 13, 2025

    CVE-2025-24343 – CtrlX OS File Write Vulnerability

    April 30, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.