Boss lesson · Unit 01
A form
One sign-up form, from label to what is sent
What you practise
- Inputs and their types, labels tied to controls, required and pattern checks, what is sent on submit
Try a question from this lesson
Pick one
The user types a@b.co and presses Join. Which URL does the browser load?
<form action="/join">
<input name="email">
<button>Join</button>
</form>Hint
The form names a destination, and the field has a name. Both end up in the address.
Correct answer
/join?email=a%40b.co
Why
A form sends each field as name=value to the URL in action. By default it uses GET, so the pairs go after a ?. The @ is written %40 because some characters are encoded in URLs.
The idea
Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.
Concept
What a form sends
On submit the browser collects every control that has a name and sends name=value pairs to the form's action.
With method="get" (the default) the pairs go in the URL. With method="post" they go in the request body, which is what you want for passwords and for anything that changes data.
<form action="/join" method="post">
<input name="email">
<button>Join</button>
</form>11 more exercises in the app
- 3× type the answer
- 4× multiple choice
- 1× match the pairs
- 1× fill the blanks
- 1× true or false
- 1× order the lines
Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.