Phone field with country code in HTML and CSS
A phone field with a country picker: the number is formatted while typing, its length is checked and it is sent in international format.
Here is an excerpt of this component's code in HTML and CSS. The full code is free for members, ready to copy into your project.
This component also comes in
The code in HTML and CSS
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Téléphone avec indicatif pays</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<main class="demo">
<form class="cti" data-cti data-cti-rules='{"FR":{"code":"33","groups":[2,2,2,2,2],"lengths":[10],"trunk":true,"example":"06 12 34 56 78"},"BE":{"code":"32","groups":[4,2,2,2],"lengths":[9,10],"trunk":true,"example":"0470 12 34 56"},"CH":{"code":"41","groups":[3,3,2,2],"lengths":[10],"trunk":true,"example":"079 123 45 67"},"LU":{"code":"352","groups":[3,3,3],"lengths":[6,7,8,9],"trunk":false,"example":"621 123 456"},"CA":{"code":"1","groups":[3,3,4],"lengths":[10],"trunk":false,"example":"514 555 0123"}}' novalidate aria-labelledby="cti-titre">
<h2 class="cti-title" id="cti-titre">Être rappelé par un conseiller</h2>document.querySelectorAll("[data-cti]").forEach((root) => {
const on = (el, type, fn) => el.addEventListener(type, fn);
const form = root;
const rules = JSON.parse(form.dataset.ctiRules);
const country = form.querySelector("#cti-pays");
const input = form.querySelector("#cti-numero");
const help = form.querySelector("[data-cti-help]");
const e164 = form.querySelector("[data-cti-e164]");
const status = form.querySelector("[data-cti-status]");
const rule = () => rules[country.value];
const digitsOf = (value) => {:root {
--cti-card: #ffffff;
--cti-text: #1a2230;
--cti-muted: #4a5466;
--cti-line: #c8d0dc;
--cti-field: #ffffff;
--cti-accent: #3730a3;
--cti-accent-text: #ffffff;
--cti-error: #b91c1c;
--demo-bg: #eceef5;
--demo-text: #1a2230;
}Free component: copy it freely, including for commercial projects.
Other forms and inputs components in HTML and CSS
Forms and inputs components in HTML and CSS
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

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

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

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

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

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