-
-
Notifications
You must be signed in to change notification settings - Fork 501
London | 26-ITP-MAY | Khaliun Baatarkhuu | Sprint 1 | Form Controls #1431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
ab59fcb
68f1c61
8fb3ab3
76ba171
208a3d6
141e0bc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,22 +6,104 @@ | |
| <title>My form exercise</title> | ||
| <meta name="description" content="" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
|
|
||
| <style> | ||
| body { | ||
| font-family: Arial, sans-serif; | ||
| margin: 20px; | ||
| } | ||
|
|
||
| form { | ||
| max-width: 400px; | ||
| } | ||
|
|
||
| label { | ||
| display: block; | ||
| margin-bottom: 5px; | ||
| font-weight: bold; | ||
| } | ||
|
|
||
| input[type="text"], | ||
| input[type="email"], | ||
| select { | ||
| width: 100%; | ||
| padding: 8px; | ||
| margin-bottom: 15px; | ||
| box-sizing: border-box; | ||
| } | ||
|
|
||
| fieldset { | ||
| margin-bottom: 15px; | ||
| } | ||
|
|
||
| button { | ||
| padding: 10px 20px; | ||
| } | ||
| </style> | ||
| </head> | ||
|
|
||
|
|
||
| <body> | ||
| <header> | ||
| <h1>Product Pick</h1> | ||
| </header> | ||
|
|
||
| <main> | ||
| <form> | ||
| <!-- write your html here--> | ||
| <!-- | ||
| try writing out the requirements first as comments | ||
| this will also help you fill in your PR message later--> | ||
| <!-- Collect the customer's name. Name contain at least 2 non-space characters. --> | ||
| <label for="name">Customer Name:</label> | ||
| <input | ||
| type="text" | ||
| id="name" | ||
| name="name" | ||
| pattern=".*\S.*\S.*" | ||
| title="Name must contain at least 2 non-space characters." | ||
| required | ||
| /> | ||
|
|
||
| <!-- Collect the customer's email address. Email must be in a valid email format. --> | ||
| <label for="email">Email Address:</label> | ||
| <input | ||
| type="email" | ||
| id="email" | ||
| name="email" | ||
| required | ||
| /> | ||
|
|
||
| <!-- Allow the customer to choose a T-shirt colour. Only provide three colour options. --> | ||
| <fieldset> | ||
| <legend>Choose a Colour</legend> | ||
|
|
||
| <input type="radio" id="red" name="colour" value="red" required> | ||
| <label for="red">Red</label> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: Here's is an alternate markup that does not involve "id" and "for" attributes.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, understood. The input is inside the label attribute, making it easier to read and needing less code. |
||
|
|
||
| <input type="radio" id="blue" name="colour" value="blue"> | ||
| <label for="blue">Blue</label> | ||
|
|
||
| <input type="radio" id="green" name="colour" value="green"> | ||
| <label for="green">Green</label> | ||
| </fieldset> | ||
|
|
||
| <!-- Allow the customer to choose a T-shirt size. Provide sizes: XS, S, M, L, XL, XXL --> | ||
|
|
||
| <label for="size">T-shirt Size:</label> | ||
| <select id="size" name="size" required> | ||
| <option value="">Choose a size</option> | ||
| <option value="XS">XS</option> | ||
| <option value="S">S</option> | ||
| <option value="M">M</option> | ||
| <option value="L">L</option> | ||
| <option value="XL">XL</option> | ||
| <option value="XXL">XXL</option> | ||
| </select> | ||
|
|
||
| <button type="submit">Submit Order</button> | ||
|
|
||
| </form> | ||
| </main> | ||
|
|
||
| <footer> | ||
| <!-- change to your name--> | ||
| <p>By HOMEWORK SOLUTION</p> | ||
| <p>By Khaliun Baatarkhuu</p> | ||
| </footer> | ||
| </body> | ||
| </html> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the user input is rejected, the browser shows "Please match the requested format" but it is not clear what the requested format is. Can you make it clearer to the user what format should a name be?
Should a name such as "C J" (with a space between two alphabets) be considered a name containing at least two non-space characters?