{
"$schema": "../schemas/code-crispies-module-schema.json",
"id": "html-forms-validation",
"title": "Validation",
"description": "Learn HTML5 built-in form validation attributes",
"mode": "html",
"difficulty": "intermediate",
"lessons": [
{
"id": "required-fields",
"title": "Required Fields",
"description": "The required attribute prevents form submission if the field is empty.
Add it to any input that must be filled:
<input type=\"text\" required>
The browser shows a validation message automatically.",
"task": "Make both the name and email fields required by adding the required attribute.",
"previewHTML": "",
"previewBaseCSS": "body { font-family: system-ui; padding: 20px; } form { max-width: 350px; } label { display: block; margin-top: 15px; margin-bottom: 5px; } label:first-of-type { margin-top: 0; } input { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; } input:invalid { border-color: #d32f2f; } button { margin-top: 20px; padding: 10px 20px; background: #1976d2; color: white; border: none; border-radius: 4px; cursor: pointer; }",
"sandboxCSS": "",
"initialCode": "