Viewers: in countries Watching now:
Forms perform an essential function in modern websites, making it possible to gather information from users and validate that information. In this course, Adobe Certified Expert Candyce Mairs shows how to create forms to email user information and validate user data using various methods of form validation. These validation methods include client-side, server-side, and custom validation; CAPTCHA images; and Spry validation fields. You'll also see how to set up a PHP testing environment and preview PHP pages in Dreamweaver. Along the way you'll build your skills in areas like using admin consoles, commenting code, working with variables and includes, and much more.
We are now going to take a look at Spry validation fields and Spry came out, I believe it was with CS3. So its been around for a few versions now, let me open up the Insert bar, by going to Window > Insert so we can take a look at those And I can create a new page. So I'll create new. And we want PHP. So I'm going to switch to Design view. Let's save this in our site files.
Notice right now, we only have one folder in our site files. And we'll name this simply spry.php. On our spry.php file, we're going to go out to the tab called spry. Now, spry is a way to add validation. What you do is, as you build your form, validation is incorporated into it. So let's add a form he and will go out to the forms tab to the proper.
And select the form here so we have a form tag without your form elements being inside a form tag it won't work correctly. now that we have our form tag which is this red dotted line entering river, we'll go back to Spry. Now I could just go over here in the forms area. Any of these oranges kind of starred pieces or icons are all spry features. So they're listed in both locations. In the Forms area and in the Spry area. You can see within spry every one of these has those orange little stars on them.
So let's create a Spry form field. I will click this first icon here, you can see there's a little vertical bars separating these groups of items from this one. I'll click Spry Validation Text Field, and we're going to add some accessibility attributes, and we'll plug in name as the ID, our label will be a capital letter N for name. Now, you can see this looks a little bit different than if you're doing regular HTML form. Let's add one more in here.
I'll put my cursor at the end of the line. Hit Return. And we'll do one more, let's do email. So I'll go out to that same Spry Validation Text Field. ID will be email, label of email with a capital E. We want the label to look nice for the user. The label is what shows up on the form. I'll click at the end and now we need a Submit button. I'll go back to the Standard Forms tab.
Go over to this one, which looks like a button, and click button. The ID is going to be submit. There we go. And we don't need a label for this one. So no label tag, we won't plug anything in there. And there's our button so we have a mini form here. I want to do a scale down version of what we're going to build in the contact desk form. Now, how do work with a Spry field. Well, the first thing I need to do is open up the properties area down at the bottom of the screen.
So I will go up to Window > Properties. Now, within this properties area, we can control our Spry form field. Before we do, I want to point out our site files only have one folder inside them. Once we finish these Spry fields and save it, we will have another folder added to our Website files. So I'll talk about that when it gets added.
Now click on the Name field, the square portion, and what we get is our Standard Text Field for HTML. So I'll set the width of name to 50 characters. I'll do the same, I'll click the box inside this area for email text field and I'll set this on to 60 characters. So I'm going to control the width of these boxes by clicking the square box inside the blue square.
So we have it and you can see this grew in terms of size in our page. We didn't do anything spry related yet. This next piece is where that comes in. Now in order to access the spry field I click on this blue tab area. So if I click the tab up here, above these two, that's how I get to the spry information. So notice it now says Spry Text Field. The way this works is, we have different preview states for our form. So this drop down, controls what each state looks like, so when the form first loads for the user, that's the initial state, that's what we're looking at here. If I change this drop down to Required, You can say what this field looks like now and a value is required.
What I'm going to do is say instead of a value is required I'm going to say a first and last name is required. Now I'm having a little difficulty getting my cursor inside this area. So what I will do is go up to split view to show you. So there's quite a bit of code that's been added within this section, specifically for Spry. Here is my message. Now you do have to be careful when you are adding information to this. And it's easy to accidentally hit Backspace too many times, and what you've done is eliminated extra code.
So it really is best to go into the Code view to do this. And I'm going to say, instead of a value is required, I'm going to say a first and last name is required. There we are now I want this to show up underneath my name field right under here instead of kind a popping over. If I move up to design view you can see there is space on the right-hand side so it's totally up to you but if you decide. You want this information to go below the Text field, hit Shift Enter in front of the a, and what that will do in Code View is simply add a Break Tag before your Text.
When you're working in Spry Form Fields, you have to be more careful about what you do. Because there are these other pieces of code around this area so, there's our name field now. I'll select the Spry tab again that is our required that's what it's going to look like to the user if they didn't fill in information I'll go down to valid. This is what it's going to look like to the user if they filled it out correctly, and it's going to be green. Now what else can I do to this field? I'll check it with the email. So let's Double-click the Spry field down here.
Okay, I have the email Spry field showing. You can see it says, spry text field two. And I know that's the correct one because as you add each one you can see this one as number 1, this one as number 2. So how do we affect this field. Well it's very similar to what we did in the name field. Its going to be white when the user first sees it, if I switch this to required. This is what it's going to look like.
So I can go in and as I said I prefer to view Split view. Here is my message. So I am going to say instead of a value is required, I am going to say an email address is required. And let me put it back to Design view. This one I can leave on the right-hand side, just so you have an example of doing both. Now that's what it looks like with an e-mail.
What does it look like (UNKNOWN) It turns green just like name. And whatever preview state you have selected, that's how it's going to remain. In the Design view. Now the other thing I wanted to do for this email address is make sure they enter an email address, and there are some other things you can validate against built into Spry. So I'll select E-mail Address. And now you can see it now says, Invalid Format.
Well, that's not the friendliest message in the world. So what I will do is, go back to Split view, and where it says, Invalid Format, I will say, Please enter a valid email address. So this one says an email address is required. This one says please enter a valid email address. So, let's take a look at our Form at this point.
Now we only have the Images folder. When I go to Save this file, Dreamweaver is going to give me this message and this means that we must add these files. It will go into a spry assets folder and I will click OK. Our files will now have spry assets. Inside our folder structure and I wanted you to actually see Dreamweaver add that folder. Which is why we did not have all the spry assets when we started this lesson.
If I click submit and don't add anything it turns red. You can see the name field. I hit the break key or shift enter on the keyboard and what that did was put this message down below the name field. Now I do have plenty of space over here where I could place it. So it's good to be consistent. I just wanted to show you you have a couple of options here. For our email, it's to the right. So If I plug in a name, and I'll just put my first name for now, click Submit, it turns green Let's try this one. I'll just put in my last name, and it says please enter a valid email address. So, it's looking for the email information.
I'll plug in my email address, click submit, And you can see it worked. Now we don't have this information doing anything. We don't have an action script for it. I just wanted you to see how to build a Spry form. These Spry form fields are all very similar, and I do have a completed Spry form for our scuba vacations website. All set for you to use.
There are currently no FAQs about Dynamic Dreamweaver Websites: Creating and Validating Forms.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.