---
name: html-form-builder-with-validation
description: "Generates a semantic, accessible HTML form with matching JavaScript validation and your chosen styling and error display, ready to paste into a page. Use when a developer needs a ready-to-paste HTML form with client-side validation, specific error messages and accessible markup. Do not use for server-side validation or a form framework integration. Related topics: html, javascript, coding."
---

# HTML Form Builder with Validation

Generates a semantic, accessible HTML form with matching JavaScript validation and your chosen styling and error display, ready to paste into a page.

## When to use

Use this skill when a developer needs a ready-to-paste HTML form with client-side validation, specific error messages and accessible markup. Do not use it for server-side validation or a form framework integration.

## Workflow

1. Ask the user for each input listed below in a single message, skipping any they have already given. Where options are listed, offer them, but accept other answers too.
2. Pick input types, autocomplete values and labels for each field, until every input has an accessible label.
3. Write validation rules for the chosen checks, until each rule has a specific error message.
4. Wire up the error display style and focus the first invalid field, until a failed submit shows errors in the chosen way.
5. Apply the chosen styling approach, until the form renders consistently without extra setup.
6. Add a note that the server must re-validate, until the response states it plainly.

## Inputs

- **Form purpose** (choose one: Contact Us, User Registration, Checkout, Survey)
- **Fields needed** (longer free text)
- **Styling framework** (choose one: Plain CSS, Tailwind CSS, Bootstrap)
- **Validation required** (choose any: Required fields, Email format, Password strength, Phone regex)
- **Error display** (choose one: Native browser tooltips, Custom inline error text, Alert box)

## Output

Three code blocks, HTML then CSS or framework markup then JavaScript, followed by a one-line note on server-side validation.

## Prompt template

Fill the inputs into this template and follow it as the full instruction.

### HTML Form Builder with Validation

Create a semantic HTML form with client-side validation.

- Form purpose: {{Form purpose}}
- Fields needed: {{Fields needed}}
- Styling framework: {{Styling framework}}
- Validation required: {{Validation required}}
- Error display: {{Error display}}

Use a label for every input, the right input type and autocomplete values, and a fieldset where fields group together. Validate on submit and on blur, never block pasting, and keep the messages specific ("Password needs at least 8 characters", not "Invalid"). Link inline errors to inputs with aria-describedby and move focus to the first invalid field. Remind the reader that client-side checks are a convenience and the server must validate again.

Return the HTML, the CSS or framework classes, and the JavaScript in separate code blocks.

## Pitfalls

- Using placeholder text instead of labels, which breaks accessibility.
- Writing a password rule that blocks paste or rejects valid passphrases.
- Treating client-side validation as security.
