Validate Name

2 minutes
Share the link to this page
Copied
  Completed
If the name syntax is not valid, then lets show an error message:

Transcript

Hello, in this video I am going to cover validating the name not the username, the name, so I'm actually going to change this slightly. So I'm going to change I know username fine this levy as that, but the validation that we're going to apply is that you can only have letters and whitespace. So imagine if it's basically a name, for example, and to do that, so obviously, once we've determined it's not empty because we don't want to do this validation, if it's empty, it is useless. Or we can do something called preg match. And basically, if this validation file for this prayer on the form match files, and this will be I will actually provide you with a link so you can get more information on how to use this but this is basically a format that I researched before I created a video and this basically just allows us to check for the former So this is a really good way of using the built in features.

And now what we need to do is specify the actual data that we are checking for which is username username bar, username for actually this should be curve. If this is empty, then we don't want it, we actually want it in the list. Notice when we had the arrows like we should not have an arrow despite default, so if this fails, then the gonna be a different username. And I just realized there's something wrong here there we go. So now the error is going to be only letters and why they are allowed. Yeah, so that we load it.

If I click Submit, we get you the name the empty if I type in form, which is my name, we get nothing. If I type in Only less than whitespace are allowed by typing my full name that's valid because it's whitespace. If I the third typing and accidentally I put in the no ampersand, and I'm putting only lettering on whitespace are allowed. So that basically validates This is a little simple way of validating, you know, name so just letters and whitespace. Like I said, I'll provide a link so you can understand more about preg match. And that's it.

If you have any questions, feel free to drop me a message. And as usual, I look forward to seeing you in the next video.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.