HTML Text Input Generator
WM-65Describe the field on a few lines and get a labelled text input, with length limits and a pattern that are checked before the HTML is written.
Runs in your browser. Nothing is uploaded.
Attribute lines: label:, name:, id:, value:, placeholder:, maxlength:, minlength:, pattern:, size:, hint:
HTML
How to use it
- Write label: and name:, then optional placeholder:, value:, minlength:, maxlength:, pattern:, size: and hint: lines.
- Tick Required and choose an autocomplete token if you want one.
- Pick the label style, wrapper and optional form.
- Copy the HTML into your page.
Pattern, minlength and maxlength
The pattern attribute is a regular expression that the whole value has to match, so you do not write ^ and $ yourself. The tool compiles your pattern with the same rules a browser uses for this attribute, and tells you if it is invalid. Maxlength stops typing past the limit, and minlength is checked when the form is submitted. Both count UTF-16 code units, not characters you see, so some emoji count as two. Minlength cannot be above maxlength, and the tool refuses that.
Label, placeholder and hint
A placeholder is a short example shown inside an empty field. It disappears as soon as someone types and is not a dependable name, so the generator requires a visible label, linked with for and id. Use the hint line for rules users need while typing, such as the allowed characters; it is attached with aria-describedby so screen readers read it after the label. The size attribute only sets the visible width in characters, not a limit on the value.
Autocomplete and validation limits
The autocomplete tokens in the list, such as name, given-name, family-name, username and organization, tell the browser what to fill in, and off turns suggestions off. Browser checks on pattern and length stop honest mistakes but can be bypassed by anyone sending a request directly, so repeat every check on the server. Values are escaped, so quotes and angle brackets in a placeholder or hint cannot break the markup.
Error messages and what to do
| Message | What it means | Fix |
|---|---|---|
Missing label. Add a line such as "label: Email address"; every input needs a visible label. | The input has no label: line. | Add label: and the text users should see. |
minlength cannot be larger than maxlength. | The minlength line is above maxlength. | Lower minlength or raise maxlength. |
Questions people ask
How do I set a maximum length on a text input?
Add maxlength with a whole number. Typing stops at that many UTF-16 code units. Add minlength for a minimum, which is checked on submit. The browser stops further typing but a paste can be cut off too. Use minlength for a floor, which only applies when the user submits.
Do I need ^ and $ in the pattern attribute?
No. The browser treats the pattern as if it were anchored to match the whole value, so [a-z0-9_]+ already means the full text. This tool checks the expression compiles.
Can I use placeholder instead of a label?
No. The placeholder disappears when typing and is not a dependable accessible name. Keep a visible label and use a placeholder only for an example.
What does the size attribute do?
It sets the visible width in characters. It does not limit what can be typed; use maxlength for that. It is a width hint only, and CSS width usually overrides it. A field can still hold far more characters than it shows.
Is the browser check enough to validate input?
No. Browser checks help users but can be skipped. Always validate again on the server. Anyone can send a request that skips the form, so the server must repeat length, pattern and type checks for every field.
About this tool
Builds a label and an input of type text. The pattern line is checked as a regular expression before the HTML is written, using the same rules browsers use for the pattern attribute, which matches the whole value without needing ^ and $. minlength cannot exceed maxlength. Length limits count UTF-16 code units, so some emoji count as two. A placeholder is only a hint and disappears while typing, so the label line is required. Autocomplete accepts a few common tokens. Client-side checks can be bypassed, so validate on the server too. Values are escaped.