Hi there and welcome back.
This lesson we're going to be checking to see if our password passes our check as well so we can get
rid of these console messages so they're not interfering with our program.
We don't need them anymore.
Get rid of all the console messages that we've been using and we're going to do a check to see if the
temp name is password.
So if it's a password, then there's a few conditions that we need to pass through there.
So passwords and our expressions.
So create a brand new expression that we're going to be looking for and for passwords.
We want to check to see if it's digits, lowercase, uppercase, all OK.
So making sure that we're checking to see if this is matching and if it is, then this is going to be
a valid password that we can use so we can also do a test.
So just as we did in the previous lesson, we've got tests and there's some more information on tests
on the material developer network.
So if you never use tests before with regular expressions, they're ideal, where you can execute a
search for a match between a regular expression and a specified string returns, true or false?
So you've got the regular expressions are here and the string is this one.
So it's testing regular expression, one triangle expression, two on the string and so on.
So we've got the expected output here so we can use test whenever we want to know.
If a pattern is found within a string, it returns a boolean value.
There's some more examples as well down below.
So let's have the Metsola developer network, so let's go ahead and bring that into our project.
So we're taking checking to see if this content is true.
We've got our test here that we're doing so.
We're using our expression with a test and testing again, that value that's contained within that element.
If the result comes back negative, then we can pass on a message.
So only numbers and and letters.
And there's one other thing that we do need within the regular expression.
And we need to sign in order to check to see if these characters match and up to the dollar sign.
So let's try that in our expression.
So we've got some letters here.
So that's OK.
If we've got special characters, only numbers and letters are valid.
So let's change these into numbers and we can see that that's all OK.
So there's one other thing that we do still need to do and that's remove out all of those error messages,
because when we try to submit it again, all of the error messages are still there.
So we can do that by looping through all of the errors that we have on the page and looping through
all of those elements with a class of error.
And through for each one of those, we can output them as a variable called item.
And then as we loop through the item, we can take the class list and add height to it.
So simply adding hyd to all of the elements and what that will do is hide it.
So when we do turn valid and if we're submitting again, if we've got some more errors, you're going
to see that they're disappearing.
And if we update this and save it and then if we make a mistake again, you're going to see it shows
up.
The error message shows up once again.
So now that's a required field.
So everything is good and we should actually be able to submit the form at this point.
Also, one other thing, if we want to check to make sure the length of our password is less than eight
characters are longer than eight characters.
So there's another condition that we can pass in.
So we've got the first condition and this condition.
So it's still checking on the password field and we can check to see if element of value is greater
than three and element.
Value and that's actually value is less than eight.
So we want a password with the length of between three and eight characters and they have to be digits
or no no special characters.
So if it's good, then we're good to pass through.
But if it's not if it's not meeting these parameters, then we want to part throw an error there.
So let's do that and we'll negotiate that with an error.
So if this is coming back as false, that we need to add in our error message and we can write needs
to be between three and eight characters.
So let's try that.
So this time in the password, we can see that we've got that needs to between three and eight.
So everything is good.
When we go over eight, we've got that message again between three and eight.
So once we've got that everything in place, we can actually submit the form and I'll show you how to
do that coming up.
So that means that none of the errors were true and we are OK to submit the form.
And if the errors are true, then we're not going to be submitting the form.
So that's still to come in the next lesson.
So go ahead and add in some additional conditions.
You can add it on password and you can also add and so on username if you want.