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

Global Attributes: placeholder and required

All forms in HTML have global attributes that are used to control them from default place holder text(new to HTML5) through the capabilituy of disabling them.

Video Transcript

00:00All right, properties. We're talking about properties. We're in the text area. I wanted to talk about two other properties that are actually, again, really to any input device or almost any input device that you're expecting the user to type something inside.
00:12Now, I separated into a separate video because the next two tags that we're going to talk about are new to HTML5, a.k.a. if you're working in an earlier browser, you won't see anything.
00:23But if you're in a modern browser, then it will work. Now, if it doesn't work, it won't do anything. So nothing to worry about.
00:30OK, so it won't create damage into your component. So I want to show you how it works. Basically, the first new attribute that we want to call out is placeholder.
00:40The idea of placeholder is said to put some copy inside of the copy area until the user starts typing.
00:47So, for example, in our placeholder area, we could type in, for example, please limit your comments to 100 characters.
01:02And if we go into our element right now and click on refresh, we'll see now, please limit your comments to 100 characters.
01:08Once you type inside and start typing, oh, by the way, we can type. So let's go back really quickly into our browser.
01:15And I'm going to grab this read only because we set it to be read only. Take it out. I'm just going to save it out there.
01:21So in case someone wants to look at it later, do you remember the character? Now that it's not read only, we could go back into our browser, click on refresh.
01:31And again, you'll see that we're please read only. It's kind of like thinned out, makes it looks really nice. Once you start typing, it goes away.
01:40This is exciting. Yeah. And once you take it out again, it's always there. So it makes it much easier to even add your explanations and instructions right inside of your text field.
01:50Now, again, you could have done it also for your username. So, for example, let's do this, for example, first name.
01:58No, for example, maybe the username up here for username where we could put here a placeholder placeholder and right here user is email is your email because some sites the user is a real real nickname.
02:15Some usernames are an email. So we're kind of reminding the user that they need to put their email in their user.
02:21So user is your email and then they could type your email so you can make it much more descriptive and more more engaging to your user, making it easier for them to convert to whatever you want them or need them to convert into.
02:33All right. So that's the placeholder new to HTML5. Any browser that is HTML compliant will automatically do this.
02:41And if your browser isn't or the user browser isn't, they just won't see this extra tidbit of information, which is not the end of the world.
02:48Next, I want to talk about is the required attribute. The required attribute basically tells the browser and the submission form that this field has to be filled out before you could submit it.
03:00That's right. Yeah. Like shopping at Macy's or something.
03:05Exactly. All right. So, for example, if we want to add it, for example, for the password and I just go to my password area, I type your space and I just write the words required.
03:16Now, traditionally, it's a really complicated process. But with the world of HTML5, the idea was to kind of like cut down the amount of work that developers need to do for stuff that are common.
03:33Now, this functionality might not be 100% functional in all browsers, so you can't really depend on it to work.
03:41You have to create your own code as well. But with this case, if we try to click on our login button without it, it's not going to tell us anything.
03:47So right now, the required is really not automatically adding any features because those features we need to actually build out ourselves.
03:54In the future, browsers will automatically be able to not submit the form if you type in that it's required.
04:01But that's kind of like a future pending something of HTML5.
04:04But in the meantime, by you setting it to be required, you're making it clear. You're making a lot of noise with your bracelet.
04:09I'm sorry, but I couldn't submit things if I didn't fill it in.
04:14Because those forms are built out with programming and those users know JavaScript, which you could learn JavaScript with us as well.
04:20And then you'll be able to create those type of forms as well. But without actually knowing JavaScript currently, there's no way to actually make sure that it will work.
04:27And even if it did work right now in this browser, you still would have to implement it in JavaScript as well.
04:33And the reason is because there's a lot of browsers out there and many users have older browsers.
04:37And you can't have your functionality, your core functionality, dependent on it.
04:41Now, on the other hand, when you have these comments, if it's not there, not the end of the world.
04:45But if your functionality is different, then it is a big deal. So you do have to implement it today in HTML5 in JavaScript.
04:52But in four or five, six years from now, you won't need to.
04:55It's going to get much easier and easier. The process of validating forms.
05:01Yeah, I don't think it's going to take four or five years. It's going to happen one, two, three things.
05:06Well, it's going to happen one, two, three.
05:08But a lot of people have old computers and they don't upgrade their computers that quickly worldwide.
05:13If you're talking about Africa and you're talking about third world countries and such of that nature,
05:18computers don't change that quickly. Technology grows really quickly.
05:22But the adaptations of users takes a really long time.
05:26Right now, I think we're Internet Explorer 12 or something like that.
05:30And there's still people working with Internet Explorer 6 from 1995.
05:34So it takes a lot of time for things to actually seep in and become a standard.
05:38So things are going to get easier for programmers in five, ten years from now.
05:43But you still need that JavaScript and you still will need it also when that comes in,
05:48because it's important to know JavaScript and we have a course on it.
05:52And you're getting really close to the end of this course.
05:54So if you're really excited about HTML and you want to become a developer,
05:58your next smart step is to learn JavaScript and even smarter learning JavaScript with us.
06:05That's right. Exactly.
06:07All right. So those are the two new tags I wanted to talk about,
06:11which are relevant to a lot of different areas.
06:14And that's it. See you in our next video,
06:17which we'll talk about a completely new tag also in the submission forms.

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!