Hello, in this video we are going to take a look at vanie datian. So just some basic form validation. So let's go to HTML. Let's create a form for starters. And in here will What should we have an input in here? I'm actually just gonna keep it simple one input.
You understand what we do we just want you to be able to type equals txt name to eat as well. The name you guys. We were messy. Oh yeah, so we got this little input right here. That's pretty darn cool one do we can get I'm putting in now. I'm actually gonna put I'm gonna go radical.
I'll have a deal with your activity. Also. Click me, click me. Click me. And I'm gonna have an ID wacky. I'm just gonna say on click on lick, lick in onClick we'll put that in.
Just put that. Keep it simple. It's a function as usual, to console log, make sure it is working. When we click it, Libya's broken. Okay. Now here, what we're going to do is we are going to say document dot docx and from here we are going to essentially access elements and we can literally do dot name.
User Name. User name dot value printing console log console dot log. Oh hello, checkmate cannot read value of undefined. Okay. username is not valid Okay, okay. Okay, so for the form I need to provide a name as well.
And foremost, they're almost they say, document dot get the epic form, then you get an element from it. Okay, say hello. We get Hello. So that's how you get it. And what we're going to do is we'll keep this printout in there honestly doesn't really matter. And I think what we'll do is create a variable for var one equals this and everything everywhere that we need it, we can just use this instead, it'd be a lot easier to here we'll have it in here.
And we'll check if it's empty. Then we'll say you know, you've been very naughty. So if it's, you know, nothing in it. Then we're gonna say console dot log. Isn't it if I put something in week we don't get that. We'll also do a nova checks the wrong one, and we want a minimum length of 10.
So dot length is next we'll say console dot log 10. Then else is over. Now, dot log and save it for reload. We get into them too. So if I just type in H e Ll all the foil character, we get Lem should be at least and as a W or data should be Dustin now fantastic before removed the day, nine Lam should be at least 10. That is validation, we can validate the contents on our page.
If you have any questions, feel free to call me a message. And as usual, I look forward to seeing you in the next JavaScript video.