Our website will be down for scheduled maintenance on Thursday, September 18, at 11 p.m. Pacific Time and should be back up by Midnight. We apologize for any inconvenience.

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

Using the Spry Validation Radio group

From: Dreamweaver CS4 New Features

Video: Using the Spry Validation Radio group

If you enjoyed the Spry Validation widgets from the last release of Dreamweaver, you will be pleased to know that Adobe has added a few new ones. For those of you that aren't familiar with Spry Validation widgets, they combine form elements, JavaScripting and CSS to give you quick and customizable client-side form validation. First, we will take a look at the Spry Validation Radio Group widget. Now, I am in the 08 exercise files folder and I've opened up the contact.htm and on this page, we have a form that's allowing our users to contact us. I am going scroll down to the personal information sections asking who are you.

Using the Spry Validation Radio group

If you enjoyed the Spry Validation widgets from the last release of Dreamweaver, you will be pleased to know that Adobe has added a few new ones. For those of you that aren't familiar with Spry Validation widgets, they combine form elements, JavaScripting and CSS to give you quick and customizable client-side form validation. First, we will take a look at the Spry Validation Radio Group widget. Now, I am in the 08 exercise files folder and I've opened up the contact.htm and on this page, we have a form that's allowing our users to contact us. I am going scroll down to the personal information sections asking who are you.

Notice that we have a space for name, email. We have a little bit of validation going on here now, because it's saying, "Hey, email is required." Location, Skype Name, and we have this little section that says, "What is the best way to reach you?" and we don't have anything there. We are going to give some radio buttons for them to select and I would like those radio buttons to validate as well. So we'll go ahead and use the new Spry Validation Radio Group widget. Alright, so go ahead and place your cursor right after the sentence, What is the best way to reach you, and we are going to insert a line break. For those of you that might not be familiar with how to do that, just Shift+Enter and that will give us a line break and it will move us down to the next line.

Now, I am going to go to my Insert panel and I am going to go to my Spry Objects and in my Spry Objects in the middle of the section here, we have some of our validation widgets> We have the Spry Validation, we have the Spry Validation Select, Password, Validation Confirm, Radio Group, so we have some new ones here. And I want to choose the Spry Validation Radio Group so I am going to click on that to add this. Now the first thing that it is going to ask me is what do you want inside this Radio Group. So we're not really dealing with any validation stuff just yet. I am going to name this rgContact to give our Radio Group a name and it comes automatically with two labels.

So let's go ahead and fill out the first two. I am going to type in Email as the first label and for the value, I am going to give it email. And notice I've used a capital E for the label and then a lowercase e for the value. I'll hit tab to the next one and I'll type in Skype and then I will just do a lowercase skype. Anybody who's used radio button before, knows what's happening here. The label is what's actually going to show up on the page, and the value is what's going to be returned with the form. We need one more so I am going to click my plus button here to add another one, another radio button and this one is going to be Yelling and it's value will be yell.

My other option is to insert this with line breaks or to use table markup. I am going to remove all the table markup from my page, so I just want to use line breaks and I'll click OK. There is our new radio group, Email, Skype and Yelling. Now, if you click on these guys individually, you can make any changes that you are used to making. So this isn't special in anyway other than the fact that you are just placing content on the page. You can still write your styles for this, you can still isolate it and do whatever you want to. Let's take a look at how we deal with the Validation widget itself. You'll notice a blue outline and a blue tab, the Spry Radio Group tab and if I click on that tab, my Properties inspector now gives me the Spry Validation Widget properties, so I can go ahead and change these.

Now the first thing I'm going to change is how and when this validates. By default, any widget is validated on the Submit of the form. Well you can change that as well. We're going to add both Blur and Change to this so that it validates whenever somebody changes the value or when they switch focus from this to something else which is perfect. Right now, we are looking at our Initial preview state, but if I grab that pulldown menu, I can also click on the Required to see what this is going to look like when it's giving them, hey, this is required. And the default text that says "Please make a selection." I am going to highlight that and change it to give it something that's a little bit more in-line with the attitude of our site. So, I am going to type in, Hey... we REALLY need an answer! And that deserves an exclamation point.

So we are just changing that. You don't have to use the default text. You can use whatever you want to, it doesn't really matter. So now we've got an invalid state as well. Let's go back to our Spry Validation widget properties. Go and click back on that blue tab and we notice over here as well that we have an Empty and an Invalid Value. I want to talk about those for just a moment. If there is one of the items that you want it to validate as if that item had been left blank, you would use an Empty value. We don't really want that but we do have a value for this particular part of form that's invalid.

The Yelling one, for example. We don't really care if somebody chooses Yelling or not. So I am going to type in yell for my Invalid Value and now in addition to our preview states of Initial/Required, we have Invalid as well. And you can see that if somebody chooses Yelling, it will now tell them to please select a valid value. Well I want to give them a little bit more of an explanation for that. So I am going to highlight this and I am going to type in, Dude, we were just kidding. Email or Skype? That way if somebody actually tells us that yelling is the best way to reach them, we can respond them by saying we were just kidding.

So now let's go ahead and save the file. Now, as soon as we save it, it's going to add a couple of files to our site. SpryValidationRadio.css and SpryValidationRadio.js. If you already have a SpryAssets directory, it will add it to an existing one and if you don't have one, it will create it for you. So I am going to go ahead and click OK and I can see, if I refresh my site, that they've added those. So after doing that, I am going to go ahead and preview this on my browser and if I just scroll down and submit a form, if I scroll back up to that area, you can see it says, "Hey, we really need an answer." Well if I start clicking on these answers that goes away.

But if I click on Yelling, notice again that it says, "Dude, we were just kidding. Email or Skype?" You can see that any sort of validation text here is red and is appearing in sort of a red outlined box. Well that's being controlled through the CSS. If you want to modify that, you could simply go into the external Spry Validation CSS file and change that, and make it look anyway that you want. You can add background graphics to it or take off the outline. It's really up to you. Whatever you'd would like to do. As you can see, the Spry Radio Group Validation widget offers us a very quick and easy way to add robust client-side validation to radio button groups.

Show transcript

This video is part of

Image for Dreamweaver CS4 New Features
Dreamweaver CS4 New Features

16 video lessons · 18618 viewers

James Williamson
Author

 

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 Dreamweaver CS4 New Features.

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.