Skip to content

Masked IBAN field in WordPress

An IBAN input grouped by 4 as you type, checking country, length and the mod-97 key, then shown masked once saved.

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

champ-iban-masque.php
<?php
/**
 * Plugin Name: Forge, Champ IBAN masqué
 * Description: Une saisie d’IBAN regroupée par 4 pendant la frappe, avec contrôle du pays, de la longueur et de la clé modulo 97, puis affichage masqué une fois enregistré. Ajoute la composition « Champ IBAN masqué » à 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-champ-iban-masque
 *
pattern.html
<!-- wp:html -->
<form class="fib" data-fib novalidate aria-labelledby="fib-titre">
        <h2 class="fib-title" id="fib-titre">Coordonnées bancaires</h2>
        <p class="fib-intro">Pour le versement de vos remboursements, par virement SEPA.</p>
        <div class="fib-field">
          <label class="fib-label" for="fib-titulaire">Titulaire du compte</label>
          <input class="fib-input" id="fib-titulaire" name="titulaire" autocomplete="name" aria-describedby="fib-aide-titulaire fib-err-titulaire">
          <p class="fib-help" id="fib-aide-titulaire">Tel qu’il figure sur votre RIB.</p>
          <p class="fib-error" id="fib-err-titulaire" data-fib-error="titulaire"></p>
        </div>
        <div class="fib-field">
          <label class="fib-label" for="fib-iban">IBAN</label>
script.js
(() => {
  if (!document.querySelector(".fib")) return;
  document.querySelectorAll("[data-fib]").forEach((root) => {
    const on = (el, type, fn) => el.addEventListener(type, fn);
    const holder = root.querySelector('[name="titulaire"]');
    const iban = root.querySelector('[name="iban"]');
    const help = root.querySelector("[data-fib-help]");
    const status = root.querySelector("[data-fib-status]");
    const hint = help.textContent;
    const countries = {
      FR: ["France", 27],
      MC: ["Monaco", 27],
style.css
:root {
  --fib-card: #ffffff;
  --fib-text: #1c1f26;
  --fib-muted: #4d5462;
  --fib-accent: #a3401b;
  --fib-line: #d3cfc9;
  --fib-error: #b42318;
  --demo-champ-iban-masque-bg: #f1ece6;
  --demo-champ-iban-masque-text: #1c1f26;
}

@media (prefers-color-scheme: dark) {

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
  • 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.

    • 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