02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School
Previous VideoNext Video

Form building Practice

In the last 5 lessons we explored forms and learned how to create them and even post them. It's a lot of content. Let's go over it one more time quickly.

Video Transcript

00:00All right, so welcome back.
00:02In our source code, I commented out our form,
00:05and I uncommented our old form and just moved our reset button
00:08into the form.
00:10And I want to just go a second really quickly,
00:12because I know that my mom is finding it a little bit hard
00:15now that we're going into user input, which I'm guessing
00:17it might be a little bit hard for you guys as well.
00:19So let's go over this really quickly.
00:21I'm going to put you in a really rough spot,
00:23because he told me it's a bit confusing just
00:24before we started recording.
00:26And I'm going to ask you to explain everything I highlight.
00:30And you're going to explain it to them.
00:31And if you're wrong, you're just going
00:32to make yourself look like a fool.
00:34I'm kidding.
00:35I'll see you later.
00:37All right, let's start from the beginning.
00:39So what is a form?
00:41Let's start from the basics of what is a form, actually.
00:44What is a form?
00:45Yeah.
00:45OK, what is a form?
00:48We'll give it a try.
00:49What is a form?
00:50What are they good for?
00:51What is their meaning?
00:52Why do we need a form?
00:53To get information.
00:55Beautiful.
00:55To enable the user to put in their information
00:58into a website.
00:59Yeah.
01:00And we said that the form has basically two different ways
01:03of working.
01:04It has an action, and it has a method.
01:07We said that the method had a POST or GET.
01:09We didn't say what it means.
01:10We just saw it in action.
01:12We said, well, ask your developer in the back end.
01:14If it's supposedly a POST or GET,
01:16don't worry about what it actually is,
01:17unless you're going to do the PHP side and the full
01:19development.
01:20And if you are, then you'll know what it means.
01:23And then we said the action itself
01:24is where we're going to send the information.
01:26In our case, we don't really know where we're sending it.
01:28So we're not really making a real form.
01:30In a real-world form, we would know
01:32what the URL, where we need to send the information.
01:35And a server will fetch the information.
01:37It's basically like an address.
01:39Well, it is an address.
01:40And we're sending the information to that address.
01:42And it'll process the information.
01:43Right.
01:44OK.
01:45Fair enough.
01:46All right, so and then what is a label?
01:52What is a label?
01:54You're asking me?
01:54I'm asking you, what is a label?
01:56Aren't you the teacher?
01:57No, I already taught it.
01:59So what is a label?
02:02A label.
02:03A label, a label, a label.
02:05I don't know.
02:07No, that's not the answer.
02:08So what is a label?
02:10Let me ask it better.
02:11What is a label?
02:12No, I'm kidding.
02:13So one is, like, take a step back.
02:18If I just put inside a text area,
02:22how would the user know what its meaning is?
02:24Like, how would he know what to put inside of here?
02:26What is the text here, which I put my name here?
02:28OK, yeah, right.
02:29I was going to say that.
02:30Your name, your password.
02:32You can't know.
02:32There's nothing here to define it.
02:34So a label enables you to basically give a scope
02:37to the user, not to the submission form.
02:39The form doesn't really care about this.
02:40This is really for the user, enabling the user
02:42to know what is expected from them
02:45to put inside of this text area.
02:46Right, right, right.
02:47Right, so that's the main goal.
02:48And that's why you have this property called for.
02:51Because you're basically connecting between the label.
02:54And for what is this?
02:56So whose label is this one?
02:59It's the user.
03:00Right, and the user is basically an ID
03:02we gave to this input area.
03:04And for this label, it's for the pass, which is the password.
03:08Exactly.
03:09So the labels basically tie in together between the user
03:12and give more information to the user about the input device.
03:16Fair enough?
03:17Now I'm going to ask you a really hard question.
03:20If I save this for a second, and I come here
03:22and I just delete the word label,
03:25and I delete all this, I just leave the word user, right?
03:29It's still going to work if I go into my browser,
03:32once I find my browser, and I click on refresh,
03:35I'm still going to see user and the submission form.
03:38So why did I need a whole special tag just for that
03:42if I could get it anyways?
03:44With the have things organized.
03:46Well, why is it good to have things organized?
03:48For who is it good?
03:50Do you have any idea?
03:54Well, now when I have this copy inside,
03:55well, a user that isn't blind
03:58could see it without any problem.
04:01If you were a blind person,
04:04and you had like some sort of a machine
04:05that's reading out the information to you,
04:08now you're putting your mouse with your Braille keyboard
04:12or whatever, you're putting your mouse on the text area.
04:14You have no idea what this is.
04:16There's no way for the browser to know
04:18that you meant it to be the user
04:20because there's no relationship between this copy
04:22and this input area.
04:24So by you putting this relationship inside
04:26is making it both for accessibility users
04:29that are disabled.
04:30It makes it much easier for them to understand
04:32when they roll over this area,
04:33they know that this is for them.
04:35For example, it might be that in a browser
04:37for someone that is a little bit blind
04:39or not completely blind,
04:40it might highlight both the label and the input area
04:43when the user goes to type in the input.
04:45It really depends on the user's browser.
04:47That's nice.
04:47But because they have this relationship,
04:49the browser has more information
04:51and the browser could be smarter
04:52and more helpful to the user.
04:54Without it, it couldn't be.
04:56It's like a computer.
04:57Well, it is a computer.
04:59And beyond that, it enables search engines
05:03to have a more clear understanding
05:05of the different relationships
05:06of things inside of your page.
05:08Because you're basically building a relationship,
05:10you're explaining what the input is.
05:13Okay, that makes sense?
05:13Yes, thank you.
05:15No problem.
05:15You made it easier.
05:17Good.
05:18All right, so now we set that for the input areas,
05:20we said that there's a lot of different types
05:21of inputs that are possible.
05:23We didn't see all and we only saw our text,
05:25we saw our password and we saw our email.
05:28Now for text, it's just text.
05:30Yeah.
05:31For password?
05:32You could have like your address,
05:33some telephone number.
05:34Right, or any open text that you wouldn't know
05:36what to put inside of it
05:37that you want the user to type in,
05:38that's not more than one line.
05:40Right.
05:41Password is something that you don't want
05:42the user to see the password.
05:43So maybe it's a hidden thing for their password.
05:45Mainly you would use that for that.
05:47Okay.
05:48Right, because you don't want someone that's
05:49next to you looking at your password.
05:51And that's why there's a special field for that.
05:53Then you see stars there instead of real copy.
05:55Right.
05:56Okay, so what is the submit type?
05:59So it knows where it's going and it'll go somewhere.
06:02Well, it already knows where it's going, right?
06:03Okay.
06:04So what is the submit type?
06:05Because it knows because we told it
06:06in the action of the form.
06:08What does the type submit give me?
06:11Okay, so it enables the user to submit
06:15what they just put in and you press the button
06:17and you submit it.
06:19Beautiful, exactly.
06:20So it's not one of the input elements,
06:22it's the one that enables you to submit.
06:23Yeah.
06:24Right, so great.
06:25We understand what the submit button is.
06:27So what is the reset button?
06:29To erase it and rewrite things in your reset.
06:33Right, exactly.
06:34It enables you to delete everything.
06:36I don't usually use that,
06:37but it's a button that's there.
06:38So if there's a form that you have
06:40a lot of stuff to fill up, it might be useful
06:42if it's something that you submit a couple of times
06:45or something of that nature.
06:46Okay, good.
06:47So we know what the submit button is,
06:49we know what the reset button is.
06:50It's time for us to learn a new tag.

Ready to Level Up Your Skills?

Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!

Enroll Now for Free!