{ "$schema": "../../schemas/code-crispies-module-schema.json", "id": "html-forms-validation", "title": "Formularvalidierung", "description": "Verwende die eingebaute HTML5-Validierung für bessere Benutzererfahrung", "mode": "html", "difficulty": "beginner", "lessons": [ { "id": "required-fields", "title": "Pflichtfelder", "description": "Das required-Attribut verhindert das Absenden des Formulars, wenn das Feld leer ist. Der Browser zeigt automatisch eine Validierungsmeldung an - kein JavaScript nötig!

Füge es zu jeder Eingabe hinzu, die ausgefüllt werden muss:
<input type=\"text\" required>", "task": "Mache sowohl das Name- als auch das E-Mail-Feld zu Pflichtfeldern, indem du das required-Attribut zu jeder Eingabe hinzufügst.", "previewHTML": "", "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } form { max-width: 320px; } label { display: block; margin-top: 15px; margin-bottom: 5px; font-weight: 500; } label:first-of-type { margin-top: 0; } input { width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 6px; box-sizing: border-box; } input:focus { outline: 2px solid steelblue; border-color: transparent; } button { margin-top: 20px; padding: 10px 20px; background: steelblue; color: white; border: none; border-radius: 6px; cursor: pointer; font-weight: 500; }", "sandboxCSS": "", "initialCode": "
\n \n \n \n \n \n \n \n
", "solution": "
\n \n \n \n \n \n \n \n
", "previewContainer": "preview-area", "validations": [ { "type": "attribute_value", "value": { "selector": "input[name='name']", "attr": "required", "value": true }, "message": "Füge required zum Namensfeld hinzu" }, { "type": "attribute_value", "value": { "selector": "input[name='email']", "attr": "required", "value": true }, "message": "Füge required zum E-Mail-Feld hinzu" } ] } ] }