Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Spry validation fields

From: Dynamic Dreamweaver Websites: Creating and Validating Forms

Video: Spry validation fields

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.

Spry validation fields

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.

Now that we have added our two spry fields, we've modified our messages, we've saved the file And Dreamweaver has added the two scri-validation scripts, one is a JavaScript script, the other is a CSS file. I'm going to go ahead and test this in the browser, let's take a look at what we've created and in the browser itself, here is our information. So I will fill this up notice when I put my cursor in it turns yellow.

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.

Show transcript

This video is part of

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now "Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Dynamic Dreamweaver Websites: Creating and Validating Forms.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

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.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.