Ready to watch this entire course?
Become a member and get unlimited access to the entire skills library of over 4,900 courses, including more Developer and personalized recommendations.Start Your Free Trial Now
- View Offline
- Installing XAMPP on a Windows system
- Installing MAMP on a Mac system
- Using admin consoles
- Creating PHP pages
- Commenting code
- Working with web forms
- Adding custom validation
- Using redirects
- Dealing with email issues
Skill Level Intermediate
Now, it says please enter an email address. If I put two characters or so in the email address, it says, please enter a valid email address. Now, this piece is not specifically testing and being real picky about the e-mail address. As I said, this is a topic that we could talk about for a long time, this is very simple. It's testing the number of characters in the email address, so I'll put in a correct email address. Let's put example in here.
Now, the first thing that's going to happen, is this is our form this is the name field on the form. In other words, that text box called name, where the user would put in their name. This is what represents whatever the user typed in to that box. And we're going to test the length of whatever the user put into that box. If its less than 1 meaning if it's 0, they didn't enter anything in that box. We're going to get a message that says please enter your name.
Once that box pops up and the user clicks Okay, it's going to put the users cursor back in that name field and let our form know do not submit, return false, don't submit the form. This next one is simply testing to see if there's an empty inside that same value area. So these are almost double checking one another, please enter your name. Focus goes back in the name field. Now, we have a similar thing going on that we just looked at with the email. So, it's going to test and see if it's empty.
If so, we're going to get a, please enter an email address. This is going to test for how many characters are in the box. And this is the one where we got, please enter a valid email address, because I put less than 5 characters into the form field for email. So, this is the email address and that's all we have set up on our form. The comments area is not going to be required. If we wanted it to be required, we could use these same if statements.