Library › Coding AI › High school students
Use the right input types in your field trip form
Practice: Setting limits and rules. About 5 minutes.
About this exercise
Your field trip permission form uses type="text" for everything. Change the email box to type="email", the phone box to type="tel" with pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}", and the date box to type="date" with min="2026-11-01". All three get required. Keep every name, id and label. Return only the form in exactly 1 code block of at most 16 lines, under 20 words of text.
Common mistakes when you ask AI for this
- Vague 'improvements'. Asked to improve, the AI adds placeholders, CSS and new fields. Try: Say exactly which inputs change and to what.
- No phone format. The AI uses type="tel" but no pattern, so any format still gets in. Try: Add: "pattern=\"[0-9]{3}-[0-9]{3}-[0-9]{4}\"."
- Forgetting the date limit. Without min, someone can still pick 2019. Try: Add: "type=\"date\" with min=\"2026-11-01\"."
- The whole page back. The AI reprints the page and explains each input type. Try: Add: "Return only the form, no text."
What a strong prompt includes
- Names the input types
- Gives the phone pattern
- Gives the date minimum
- Asks for required
- Asks for only the form
Related exercises
- Add a cron line that matches the others in a crontab (Coding AI · Product managers)
- Add dark mode by overriding your existing CSS variables (Coding AI · Software developers)
- Add input checks to your number guessing game (Coding AI · High school students)
- Add input validation to a Java method with exact messages (Coding AI · Software developers)
- Add labels to a signup form without rewriting the page (Coding AI · High school students)