Okey dokey.
Let's get on to example number two.
I just want to spice things up.
I want you to show you now that we can do a few different things.
Firstly, why don't we set the target attribute to _blank.
Remember what the target attribute does?
It tells us where we want the response to be shown to us. And here, because maybe we don't want to keep
refreshing the page or having to go back,
maybe we want it to be opened in a new page.
So let's put target=_blank - just mixing things up.
And as I mentioned, I want to use the two HTML5 attributes, right?
I want to use pattern, and I want to use required.
Well, firstly, actually there's another one I want to use and that's title.
So firstly, let's use pattern.
This allows us to use regular expressions.
I know, I know.
I haven't yet spoken about regular expressions, so let's just do this example.
And in the next lecture I'll give you a quick rundown of what regular expressions are.
But this is not a course on regex.
So this is just very high level.
Let's say in our password we require the password to begin with a letter, and it needs to contain at
least one digit.
How can we do that?
Well, we need a way to develop a pattern to tell the browser that we're looking for a pattern.
And we do that using regular expressions.
And the way, or the format of a regular expression, is very peculiar or specific.
So you have to follow certain rules.
So firstly, we want to say that it has to begin with a character, right?
It has to begin with a letter.
So that's what this first part is saying.
And we can have as many characters or letters as we want.
Then at some point it has to contain a digit, at least one digit between 0 and 9.
And after that, of course, it can contain any characters.
Doesn't have to even contain anything if you don't want to. But it should have at least one digit.
So that's the pattern attribute.
And I'm going to be talking about regular expressions next.
So don't worry if you don't understand this. Then if an error message is shown to a user, I want to
be in control of what the browser shows to a user.
So let's just say "Please enter a valid password.
The password must begin with a letter and contain at least one digit."
So now we've used the pattern attribute.
We've used the title attribute.
Finally, I want the required attribute because the password is a required field.
Let's save this, go to our browser.
And firstly, I just want to mention I don't like creating rules in passwords without showing the user.
So normally I would make it very explicit, just like we saw
let me show you here, if we go to MailChimp,
let's just go on their website quickly, and we go sign up free.
Right.
They've done it in a very nice way because under the password, they've given you a lot of hints as
to what their password requires.
One lowercase, uppercase, one number, one special character and eight characters minimum.
So this is a very cool example.
And as you start typing, you know, you have a very clear visual representation of what's going on
and what's required.
Let me just close that.
So in our case, we don't have that, so I don't like it, but I just wanted to show you these attributes
and what they can do.
So if firstly, I just type one letter and I click submit, we get our title, our error message, right?
"Please enter a valid password.
The password must begin with a letter and contain at least one digit."
How cool is that?
All right, so now let's begin with a letter.
And we use a number.
Let's just say the letter A and the number 7.
How's that?
And Wally, let's now click send and there we go.
It allows us to submit the form.
If we just have Wally and a letter,
but no number, a whole lot of just random characters, and we click "Send", we will be prevented from
doing so.
How cool, how cool students.
But as I mentioned, what exactly is a regular expression?
Well, before I move on in the course, let me just take a moment to give you a high level overview
of a regular expression.