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

Using Spry validation widgets

From: Dreamweaver CS5 Essential Training

Video: Using Spry validation widgets

Occasionally you'll create forms that have information that the user is required to fill out. Our registration form for example will require a username and password to be submitted before the user can register for our site. How we inform the user of this requirement is up to us. But it is fundamental to good form design. One option is to simply write the requirement next to the form element. A more thorough option is to add some type of form validation to your form. Form validation comes in two flavors: server-side and client-side.

Using Spry validation widgets

Occasionally you'll create forms that have information that the user is required to fill out. Our registration form for example will require a username and password to be submitted before the user can register for our site. How we inform the user of this requirement is up to us. But it is fundamental to good form design. One option is to simply write the requirement next to the form element. A more thorough option is to add some type of form validation to your form. Form validation comes in two flavors: server-side and client-side.

Server-side validation requires server side code and is a little outside the scope of this class. Client-side validation uses JavaScript to check the form when it is submitted or if the form element changes to see if everything that is required is filled out properly. If not, the user is then givenfeedback and an opportunity to correct the form. Dreamweaver has long had client-side validation available in the form of a behavior. The Validate Form behavior would trigger a simple warning dialog box to inform the user of the error.

Although effective, it definitely left something to be desired in the way of presentation. Well, starting with Dreamweaver CS4 Adobe added Spry Validation widgets to its capabilities. These widgets allow robust client-side validation that is easy to control and style even if you don't know anything about JavaScript. So, if you've been wondering about that hole in our form, we're about to fill it. So I've got the join.htm file open from the 12_16 directory and this middle login area is totally empty. We need to fix that.

So, go ahead and place your cursor inside that fieldset and hit Return. Now, don't freak out if Login Information shows down here. Remember Dreamweaver just having a hard time to display that. It's okay. And what we're going to do is we are going to go up to our form objects and these little green icons on the right-hand side those are your Spry Validation widgets. The first we are going to use is a Spry Validation text field. I am going to go ahead and click to add that, and you are going to see the Input Tag Accessibility Attributes come up just as you would within the other form element. And that's one of the most popular misconceptions that I want to go ahead and get rid of right here.

Some people are under the mistaken impression that a Spry Validation form widget is unlike your other form elements. It's not. It is a form element. The only thing that's different is there's a little bit of code wrapped around it that helps the JavaScript know what to do with that specific form element. Okay. So, for this ID we're going to type in user_name. The label is going to be User Name. So that will be the user name they are able to choose and the only other thing we are going to change is Tab Index is going to be 70. Let me click OK and place it on the page.

Now just like any other form element you can style them, so I am going to go ahead and click the text box to select it, so I am going to focus right there on the text input and I am going to change the Class to text. There you go! So, that is it's the same width and the same layout arrangement as our other text fields. So, when you first start out you won't really see any difference. Now, how do these things differ? Well, you see they have a blue outline around them and we have a blue tab in the upper left-hand corner. Go ahead and click that blue tab. Your Properties Inspector is now going to reflect the properties of your Spry Validation widget.

For Type, I am just going to grab the pull-down menu and take a look at these options, but for what we're doing here for the username, we are going to allow anything to be typed in. If you needed to filter this, for example, if it needed to be a phone number or an e-mail address or a ZIP code, you can go ahead and do that and the Spry Validation widget will basically look for that type of an object typed into it. We are actually not going to put any constraints on this. We just want it to be required. Now your form validation field is going to have several preview states, based upon the options that you choose.

The initial value is going to be like any other text field. However, notice what happens if somebody doesn't fill it out. They are going to get this message. So, if you grab the Preview state and go down to Required, they are going to get this message right here. A value is required. Well, you're free to customize that. So, what I am going to do is I am going to leave the word required in there. I am going to remove "A value is" and I am going to put brackets on either side of the word required, just like that. So now, when it reads required, it will have those little brackets around it and it's just a little bit more of a subtle message if you will. Now, I am going to be honest with you. Sometimes those can be hard to change.

For some reason when you highlight them sometimes, it deletes the entire text field. It can be a little tricky. So, just to show you how this is set up within your code, if I switch to a Split Screen View, with this in code, you can see that this text is just sitting right here inside of the span tag. So, if you wanted to, you could go in code and you could type in anything you wanted to within that span tag and it would work out just fine. Okay, the next thing I will need to set is when I want this to validate. Validation basically is asking you, when should I check? By default when the form is submitted, the JavaScript is going to check the form element, but you can also say, hey, whenever somebody types in it and if somebody loses focus, so if they were to click into it and then click off of it, it would validate at that point as well. Okay, cool! I am going to take it back to its initial state, then I am going to place my cursor right out beside the existing form validation and hit Return to go down to the next line.

Now, next we need a password. So, I am going to go up to my Validation widgets and I am going to find the Spry Validation Password. It is the third item from the right, right there. I am going to click on that and once again we are going to give this an ID and this one is going to be pwd and the label is going to be password and the Tab Index for this one is going to be 80. Well, now that we have sort of seen how this works, they can be pretty quick to set up. I am just going to click the text field, use the Properties Inspector to give it the text Class so that it gets the same width, and then click the blue tab so that I can set my individual properties for this Spry widget.

Now here we are going to have some requirements. Each password has to be at least six characters long, so I am going to type in a minimum character of 6. You can see that triggers the message, minimum number of characters not met. I am going to go through my messages in order. I am going to grab the Previous states and hit Required. I am going to do the exact same thing. I am just going to highlight that. Type in a bracket. Type in a bracket on the either side of that. Click on the tab again. This time I am going to choose Minimum number of characters not met. I am going to highlight that and I'm going to change that to must be at least six characters.

So, you can get as descriptive with this as you want. Again, I am going to put those brackets in there. It's just my kind of way of visually formatting this to be a little bit different. You don't have to use those. I am just using them from a purely decorative standpoint. Now next, I'm going to preview the Valid state. It just happens to be a nice green checkbox, but of course, you can change that as well if you want to. Okay, so everything is looking good there. Finally, I am going to validate that on Blur and Change as well and then save the file. Now, as soon as I save this file, I want to point out to you what's going to happen here.

All these Spry assets, SpryValidationPassword.css, the JavaScript, everything required for these form validation widgets is going to be copied to my site. If I don't already have a SpryAssets folder, it's going to create one for me in the root directory and it's going to copy the files there. Now, as long as I maintain the relationship between this file and those files, we're going to be fine. If I upload this site to my remote site, as long as I make sure that those folders stay in the same relation, I am going to be okay. If I start moving those around without telling Dreamweaver to update the links, it can cause some issues.

So as we get towards the close of this particular movie, I am going to show you how to control where those go with a little bit greater detail. So, I am going to go ahead and click OK and I actually see there is my SpryAssets folder right there. Now Dreamweaver may come up and tell you that there is a syntax error. That is typically incorrect. It's just kind of a little bug that I don't think they've worked out quite yet. So, if you see that in your version, don't worry about it. Everything is okay. I am going to click right out beside my Spry Validation widget, hit Return to go down to the next line, and the last validation widget we are going to put on there is a Spry Validation Confirm.

If somebody is going to type in a password, they can't see what they are typing in. So, you want to make sure that they didn't make a misspelling or something that's going to cause them not to be able to log into your site. So, I am going to click right here on the Spry Validation Confirm widget. The ID for this one is going to be confirm, the label for this one is going to be Confirm Password, and the Tab Index for that is going to be 90. Once again, we are going to use some very similar things here. I am going to click on the text field and using the pulldown menu from my Properties Inspector, I am going to assign the text Class to it.

And then clicking on the blue tab for the Spry Confirm widget, I am going to make sure it's validating against the password. It picks up on that automatically, but you might want to just verify that and make sure that it is. For my preview states, I am going to go down to Required. Again, I'm just going to do the same thing I've been doing. Let's surround that in brackets and get rid of any of the other punctuation. And then finally, go down to the invalid and instead of saying the values don't match, I am just going to type in bracket, mismatch, please try again. I always like being polite, at least most of the time. There we go! And I am going to invalidate that on Blur and on Change as well.

Now, I am going to do a Save All and you will notice it's going to add even more. So, each one of these Spry widgets have their own set of files that's just going to copy over. So, you could wait until you have added all these and just add them all at once or you could it like we have done it here, which is to do it incrementally. Now, one last thing, guys. We are almost ready to test this, but you'll notice that the default styling for this, sort of a red text with a red box surround it, doesn't really match our site. Well, that's okay. The CSS is being driven by these external pages up here, but that's not to say that we can't change them. So here's what we're going to do.

I want you to take each one of these and click on the tab for the validation widget and choose one of the required states. It doesn't matter which one. Just choose one of the required states. There we go! We are going to go ahead and style these guys all individually by using the Code Navigator and it's the easiest way to find the targeted selectors that we need. So, I am going to hold down my Alt key and click on this text. On the Mac you would want to hold down the Command option and we're looking not in our CSS. We're looking in Dreamweaver's CSS.

If we thought our CSS is complicated, look at that. We are going to find these really long group selectors and you want to click on that and soon as you do, it will jump you into Code View and these guys are just kind of stacked one on top of each other. We are just going to change the color. I am going to change it from the CCC to 51341a. That's thatbrown color. And then for border, I am just going to change that to none. I have got my brackets. I really don't need that border. I am going to scroll through this code and see if that appears anywhere else, that display in-line color and border. It doesn't.

So, we are good in this one. All right, we'll do a Save All. I am going to do the exact same thing again. I am going to go right over here. I am going to hold down my Alt key and click, that would Command+Option on the Mac, find which of those guys has the display color and border properties and click. It will jump me right to that spot, and all I have got to do is type in that color value. Again, if I was smart, I would have copied it. 51341a and border of none. Here we go! I will again look through this to make sure that we didn't miss anybody.

I think we're okay. We'll do a Save All and we are going to finish it up by going right here and doing it again. So, trigger your Code Navigator, find the one with the display color and border properties, and just switch those out. So, the brown color for that red color. It's 51341a and a border of none. So, when you're working with any of these Spry objects, the validation widgets included, don't be nervous about going in and changing their CSS.

That's why they made these, so that you could go in there and style them the way you wanted them to look. So, just because there is a default look to something, it doesn't mean that you have to be tied to that. So again, go ahead and do a Save All and then let's preview that in a browser and see how that works. So, if I go down to this area of the form, if I click in User Name, I'll just hit Tab to ignore it. You'll notice that my browser is now telling me this is required. As soon as I type in a password, it tells me it has to be at least six characters, so I can do that. And then if these values don't match, it's going to let me know they don't match and I just get to keep trying it. So, cool! Also notice that the focus on these is exactly the same color, that sort of cream color, so we have got a lot of consistent styling throughout our form, which is exactly what we want.

Now by using Spry Validation widgets in your form, you can add rich client-side form validation that guides users through filling out your form. It's worth noting that the JavaScript and CSS used to drive the validation widgets are fully customizable. So, changing how the validation notifications are formatted is as easy as changing out the CSS.

Show transcript

This video is part of

Image for Dreamweaver CS5 Essential Training
Dreamweaver CS5 Essential Training

135 video lessons · 89071 viewers

James Williamson

Expand all | Collapse all
  1. 2m 57s
    1. Welcome
      1m 8s
    2. Using the exercise files
      1m 49s
  2. 7m 50s
    1. What is Dreamweaver?
      3m 16s
    2. Learning web design
      2m 22s
    3. Current web standards
      2m 12s
  3. 43m 9s
    1. The Welcome screen
      4m 5s
    2. Windows and Mac interface differences
      2m 23s
    3. The Application toolbar
      4m 7s
    4. The Document toolbar
      4m 40s
    5. Arranging panels
      8m 19s
    6. Managing workspaces
      7m 32s
    7. The Properties Inspector
      5m 54s
    8. The Insert panel
      6m 9s
  4. 25m 45s
    1. Basic site structure
      3m 11s
    2. File naming conventions
      1m 49s
    3. Defining a new site
      4m 35s
    4. Managing sites
      4m 51s
    5. Managing files and folders
      6m 36s
    6. Working with browsers
      4m 43s
  5. 27m 21s
    1. Creating new documents
      5m 16s
    2. New document preferences
      3m 6s
    3. Setting accessibility preferences
      4m 56s
    4. Working with starter pages
      3m 46s
    5. Managing starter pages
      10m 17s
  6. 30m 2s
    1. Basic tag structure
      2m 15s
    2. Adding structure to text
      8m 20s
    3. Creating lists
      9m 59s
    4. Getting text into Dreamweaver
      5m 59s
    5. Importing Word documents
      3m 29s
  7. 1h 17m
    1. Understanding style sheets
      2m 16s
    2. The anatomy of a CSS rule
      1m 48s
    3. Setting CSS preferences
      6m 36s
    4. The CSS Styles panel
      10m 2s
    5. Controlling CSS through the Properties Inspector
      5m 14s
    6. Using the Code Navigator
      7m 21s
    7. Using CSS Enable
      6m 45s
    8. Understanding element selectors
      8m 11s
    9. Understanding class selectors
      8m 49s
    10. Understanding ID selectors
      5m 59s
    11. Understanding descendant selectors
      6m 51s
    12. Attaching external style sheets
      7m 44s
  8. 1h 47m
    1. Working with units of measurement
      7m 11s
    2. Declaring font families
      9m 39s
    3. Controlling font sizing
      9m 9s
    4. Controlling weight and style
      8m 0s
    5. Controlling line height
      8m 29s
    6. Controlling vertical spacing with margins
      12m 3s
    7. Controlling spacing with padding
      5m 39s
    8. Aligning text
      8m 26s
    9. Transforming text
      5m 36s
    10. Writing global styles
      15m 42s
    11. Writing targeted styles
      17m 37s
  9. 1h 32m
    1. Understanding image types
      5m 3s
    2. Managing assets in Dreamweaver
      12m 51s
    3. Setting image accessibility preferences
      4m 20s
    4. Setting external image editing preferences
      3m 52s
    5. Placing images on the page
      7m 37s
    6. Photoshop integration
      5m 54s
    7. Modifying Smart Objects
      5m 51s
    8. Alternate Photoshop workflows
      8m 8s
    9. Modifying image properties
      11m 14s
    10. Styling images with CSS
      7m 11s
    11. Using background graphics
      9m 3s
    12. Positioning background graphics
      11m 6s
  10. 55m 16s
    1. Link basics
      3m 37s
    2. Setting site linking preferences
      2m 14s
    3. Creating links in Dreamweaver
      11m 1s
    4. Absolute links
      5m 8s
    5. Using named anchors
      11m 19s
    6. Linking to named anchors in external files
      2m 44s
    7. Creating an email link
      5m 24s
    8. Creating CSS-based rollovers
      13m 49s
  11. 1h 34m
    1. CSS structuring basics
      2m 56s
    2. The Box Model
      13m 21s
    3. Understanding floats
      6m 53s
    4. Clearing and containing floats
      8m 56s
    5. Using relative positioning
      4m 8s
    6. Using absolute positioning
      7m 18s
    7. Creating structure with div tags
      12m 7s
    8. Styling basic structure
      10m 34s
    9. Creating a two-column layout
      10m 37s
    10. Using Live View and CSS Inspect
      7m 51s
    11. Using Browser Lab
      9m 39s
  12. 56m 22s
    1. Reviewing table structure
      7m 41s
    2. Importing tabular data
      5m 13s
    3. Creating accessible tables
      9m 56s
    4. Using thead and tbody tags
      4m 0s
    5. Basic table styling
      8m 45s
    6. Styling table headers
      7m 52s
    7. Styling column groups
      4m 22s
    8. Creating custom table borders
      5m 1s
    9. Styling table captions
      3m 32s
  13. 1h 43m
    1. How forms work
      3m 0s
    2. Reviewing form design
      3m 2s
    3. Creating accessible forms
      7m 33s
    4. Setting form properties
      4m 6s
    5. The fieldset and legend tags
      4m 32s
    6. Inserting text fields
      5m 58s
    7. Inserting list menu items
      5m 26s
    8. Inserting checkboxes
      7m 50s
    9. Inserting radio button groups
      6m 22s
    10. Inserting text areas
      4m 12s
    11. Inserting submit buttons
      3m 37s
    12. Basic form styling
      12m 0s
    13. Form element styling
      8m 52s
    14. Styling form layout
      11m 49s
    15. Adding form interactivity
      2m 47s
    16. Using Spry validation widgets
      12m 49s
  14. 1h 23m
    1. Planning for templates
      10m 51s
    2. Creating a new template
      10m 37s
    3. Using editable attributes
      13m 43s
    4. Creating optional regions
      6m 23s
    5. Creating new pages from a template
      9m 17s
    6. Applying templates to existing pages
      6m 9s
    7. Working with nested templates
      7m 56s
    8. Working with repeating regions
      12m 58s
    9. Modifying templates
      5m 41s
  15. 40m 14s
    1. Behaviors overview
      3m 47s
    2. Hiding and showing elements
      9m 18s
    3. Spry overview
      4m 4s
    4. Using Spry widgets
      11m 36s
    5. Adding Spry effects
      3m 6s
    6. Using the Widget Browser
      8m 23s
  16. 28m 18s
    1. Inserting Flash files
      5m 4s
    2. Setting properties for Flash
      6m 27s
    3. Dreamweaver and Flash integration
      6m 6s
    4. Encoding Flash video
      6m 10s
    5. Adding Flash video
      4m 31s
  17. 45m 28s
    1. Running site-wide reports
      6m 33s
    2. Checking for broken links
      5m 41s
    3. Checking for browser compatibility
      8m 3s
    4. Adding remote servers
      8m 0s
    5. Uploading files
      7m 20s
    6. Managing remote sites
      9m 51s
  18. 34s
    1. Goodbye

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


You have completed Dreamweaver CS5 Essential Training.

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

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?


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.