HTML Forms with Validation
Creates accessible HTML forms with various input types, built-in validation attributes, proper labeling, and user-friendly error messaging.
Code
<form action="/submit" method="POST" novalidate>
<fieldset>
<legend>Contact Information</legend>
<div class="form-group">
<label for="name">Full Name <span class="required">*</span></label>
<input type="text" id="name" name="name" required
minlength="2" maxlength="50"
autocomplete="name"
placeholder="John Doe">
</div>
<div class="form-group">
<label for="email">Email Address <span class="required">*</span></label>
<input type="email" id="email" name="email" required
autocomplete="email"
placeholder="[email protected]">
<span class="error" id="email-error"></span>
</div>
<div class="form-group">
<label for="phone">Phone Number</label>
<input type="tel" id="phone" name="phone"
pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}"
placeholder="555-123-4567">
</div>
<div class="form-group">
<label for="age">Age</label>
<input type="number" id="age" name="age"
min="18" max="120" value="25">
</div>
<div class="form-group">
<label for="country">Country</label>
<select id="country" name="country" required>
<option value="">Select...</option>
<option value="us">United States</option>
<option value="uk">United Kingdom</option>
<option value="ca">Canada</option>
</select>
</div>
<div class="form-group">
<label>
<input type="checkbox" name="subscribe" checked>
Subscribe to newsletter
</label>
</div>
<button type="submit">Submit Form</button>
</fieldset>
</form>This form demonstrates various input types (text, email, tel, number, select, checkbox) with HTML5 validation attributes (required, minlength, pattern, min/max). Each input has an associated <label> for accessibility. autocomplete attributes help browsers pre-fill fields. <fieldset> and <legend> group related inputs.
Interactive Tools for This Topic
JSON to Zod Schema ConverterInfer typed Zod z.object schemas from JSON payloads locally, supporting nested objects, merged array shapes, enums, nullable fields, and JSDoc comments.JSON Schema ValidatorValidate JSON data against a JSON Schema definition and get detailed error reports. Supports type checking, required fields, and common constraint validation.JSONL / NDJSON InspectorValidate NDJSON and JSON Lines line-by-line, pinpoint syntax errors by line number, analyze key frequencies and types, and export a pretty JSON array.Credit Card Brand DetectorIdentify the card network from a number's prefix and length, validate the Luhn checksum, and show a masked form and the issuer identification number.
Report a problem with this exampleOpens a pre-filled issue on GitHub.