{ "$schema": "../../schemas/code-crispies-module-schema.json", "id": "html-forms-basic", "title": "نماذج HTML", "description": "تعلم إنشاء النماذج بأنواع حقول مختلفة", "mode": "html", "difficulty": "beginner", "lessons": [ { "id": "form-structure", "title": "هيكل النموذج", "description": "كل نموذج يحتاج غلاف <form>. بداخله، استخدم <label> لوصف الحقول و <input> لإدخال البيانات.

سمة for في التسميات يجب أن تطابق id في الحقول للوصولية.", "task": "أنشئ نموذجاً مع:
1. <label> بالنص الاسم: وسمة for=\"name\"
2. <input> نصي بسمات id=\"name\" و name=\"name\"", "previewHTML": "", "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } form { max-width: 300px; } label { display: block; margin-bottom: 5px; font-weight: 500; } input { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; }", "sandboxCSS": "", "initialCode": "", "solution": "
\n \n \n
", "previewContainer": "preview-area", "validations": [ { "type": "element_exists", "value": "form", "message": "أحط كل شيء بعنصر <form>" }, { "type": "element_exists", "value": "label", "message": "أضف <label> لحقلك" }, { "type": "element_exists", "value": "input", "message": "أضف عنصر <input>" }, { "type": "attribute_value", "value": { "selector": "label", "attr": "for", "value": null }, "message": "أضف سمة for للتسمية" }, { "type": "attribute_value", "value": { "selector": "input", "attr": "id", "value": null }, "message": "أضف سمة id لحقلك" } ] }, { "id": "input-types", "title": "أنواع الحقول", "description": "أنواع الحقول المختلفة توفر لوحات مفاتيح وتحقق مناسب:

type=\"text\" - نص عام
type=\"email\" - بريد إلكتروني مع تحقق @
type=\"password\" - أحرف مخفية
type=\"number\" - لوحة مفاتيح رقمية
type=\"tel\" - لوحة مفاتيح هاتف", "task": "أنشئ نموذج تسجيل دخول بحقلين:
1. حقل بريد: <label for=\"email\">البريد:</label> و <input type=\"email\" id=\"email\">
2. حقل كلمة مرور: <label for=\"password\">كلمة المرور:</label> و <input type=\"password\" id=\"password\">", "previewHTML": "", "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } form { max-width: 300px; } label { display: block; margin-top: 15px; margin-bottom: 5px; } label:first-child { margin-top: 0; } input { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; }", "sandboxCSS": "", "initialCode": "
\n \n
", "solution": "
\n \n \n \n \n \n
", "previewContainer": "preview-area", "validations": [ { "type": "element_exists", "value": "input[type='email']", "message": "أضف حقل بـ type=\"email\"" }, { "type": "element_exists", "value": "input[type='password']", "message": "أضف حقل بـ type=\"password\"" }, { "type": "element_count", "value": { "selector": "label", "min": 2 }, "message": "أضف تسميات لكلا الحقلين" } ] }, { "id": "submit-button", "title": "زر الإرسال", "description": "النماذج تحتاج طريقة لإرسال البيانات. استخدم:

<button type=\"submit\"> - مفضل، محتوى مرن
<input type=\"submit\"> - زر نص بسيط

نص الزر يجب أن يكون موجه للعمل (مثل تسجيل الدخول، 'التسجيل'، 'إرسال').", "task": "أضف زر إرسال للنموذج بالنص تسجيل الدخول.", "previewHTML": "", "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } form { max-width: 300px; } label { display: block; margin-top: 15px; margin-bottom: 5px; } label:first-child { margin-top: 0; } input { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; } button { width: 100%; margin-top: 20px; padding: 10px; background: #1976d2; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 16px; } button:hover { background: #1565c0; }", "sandboxCSS": "", "initialCode": "
\n \n \n \n \n \n \n
", "solution": "
\n \n \n \n \n \n \n \n
", "previewContainer": "preview-area", "validations": [ { "type": "element_exists", "value": "button[type='submit'], input[type='submit']", "message": "أضف زر إرسال لنموذجك" }, { "type": "element_text", "value": { "selector": "button", "text": "تسجيل الدخول" }, "message": "يجب أن يعرض الزر تسجيل الدخول" } ] } ] }