Skip to content

Contact form that copes with long labels in WordPress

A quote request form whose labels, hints and error messages are full French sentences, still readable at 320 px: nothing overflows, nothing is cut off, and each error is tied to its field.

Here is an excerpt of this component's code in WordPress. The full code is free for members, ready to copy into your project.

This component also comes in

Open in a new tab

The code in WordPress

formulaire-contact-textes-longs-francais.php
<?php
/**
 * Plugin Name: Forge, Formulaire de contact tolérant aux libellés longs
 * Description: Un formulaire de demande de devis aux libellés, aides et messages d’erreur rédigés en phrases complètes, qui restent lisibles à 320 px : rien ne déborde, rien n’est tronqué, et chaque erreur est reliée à son champ. Ajoute la composition « Formulaire de contact tolérant aux libellés longs » à l'éditeur de blocs.
 * Version: 1.0.0
 * Requires at least: 6.6
 * Requires PHP: 8.1
 * Author: Forge
 * License: GPL-2.0-or-later
 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain: forge-formulaire-contact-textes-longs-francais
 *
pattern.html
<!-- wp:html -->
<div class="fcl" lang="fr" data-fcl>
        <form class="fcl-form" id="fcl-formulaire" action="#fcl-formulaire" novalidate aria-labelledby="fcl-titre" data-fcl-form>
          <div class="fcl-head">
            <p class="fcl-eyebrow">Menuiserie Lefebvre-Desmoulins · Angers</p>
            <h2 class="fcl-title" id="fcl-titre">Demandez votre devis de menuiserie sur mesure</h2>
            <p class="fcl-lead">Réponse sous deux jours ouvrés, avec une proposition de rendez-vous pour prendre les mesures chez vous. Tous les champs sont obligatoires, sauf mention contraire.</p>
          </div>
          <div class="fcl-summary" tabindex="-1" role="group" aria-labelledby="fcl-resume-titre" hidden data-fcl-summary>
            <h3 class="fcl-stitle" id="fcl-resume-titre" data-fcl-summary-title>Des champs sont à corriger avant l’envoi</h3>
            <ul class="fcl-slist" data-fcl-summary-list>
              <li><a class="fcl-slink" href="#fcl-nom"></a></li>
script.js
(() => {
  if (!document.querySelector(".fcl")) return;
  document.querySelectorAll("[data-fcl]").forEach((root) => {
    const on = (el, type, fn) => el.addEventListener(type, fn);
    const $ = (selector) => root.querySelector(selector);
    const form = $("[data-fcl-form]");
    const summary = $("[data-fcl-summary]");
    const list = $("[data-fcl-summary-list]");
    const done = $("[data-fcl-done]");
    const count = $("[data-fcl-count]");
    const model = list.firstElementChild.cloneNode(true);
    const field = (name) => form.elements.namedItem(name);
style.css
:root {
  --fcl-scheme: light;
  --fcl-card: #fffdf9;
  --fcl-text: #2a1f19;
  --fcl-muted: #5a4d45;
  --fcl-accent: #8a3b12;
  --fcl-on-accent: #ffffff;
  --fcl-line: #85766c;
  --fcl-soft: #f6ede6;
  --fcl-error: #b42318;
  --fcl-error-soft: #fdf0ee;
  --demo-formulaire-contact-textes-longs-francais-bg: #ece5dd;

Free component: copy it freely, including for commercial projects.

Forms and inputs components in WordPress
  • A quote request form for tradespeople: the customer describes the work, picks a start date range and attaches up to six site photos, each with a preview, its size and a button to remove it.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • Visitors pick a package and tick options: the pre-tax total, VAT and total including tax update live, and the summary is sent with the contact form.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A short NPS survey: a 0 to 10 score as radio buttons, then a follow-up question adapted to whether the customer is a detractor, passive or promoter.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • An honest unsubscribe page: address prefilled from the link, choice between stopping everything or receiving less, optional reason and an undo.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A callback request form: French phone number checked and formatted, topic, working day and time slot, with explicit consent to the call.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A SIRET or SIREN field that checks the Luhn key as you type, handles the La Poste exception, formats the number and links to the official business directory.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component