Working with Data on the Web
Illustration by John Hersey

Integrating HTML5 form controls


From:

Working with Data on the Web

with Joseph Lowery

Start your free trial now, and begin learning software, business and creative skills—anytime, anywhere—with video instruction from recognized industry experts.

Start Your Free Trial Now

Video: Integrating HTML5 form controls

HTML5 brought a lot of cool new toys to the table, but one area was especially welcome and needed and that's forms. There were numerous enhancements to form elements as part of the HTML5 specification, many of which have been implemented in modern browsers. In this lesson, we'll take a look at some of the most valuable changes and how you can best take advantage of them. I have open here the index.htm file from the chapter one 0103 folder of the exercise files.
please wait ...
Watch the Online Video Course Working with Data on the Web
2h 21m Intermediate Aug 21, 2013

Viewers: in countries Watching now:

Often, designers need to convey simple data without the overhead of a relational database such as MySQL. This course introduces web technologies that make it easy for a designer or developer to store, retrieve, and display data online.

First, discover how data is collected via standard and advanced HTML5 forms. Then look at a client-friendly approach to storing that data using simple CSV files. Next, Joseph shows how to store, manage, and style data with the three big players: the granddaddy of static data, XML; the popular JavaScript-based JSON; and the recursively named YAML (YAML Ain't Markup Language), frequently used in Ruby-based projects. Plus, take a close look at basic HTML5 data options, including local storage and the flexible data attribute.

Topics include:
  • Interacting with data through HTML forms
  • Storing data as comma-separated values
  • Saving, retrieving, and displaying data as XML
  • Setting up and updating JSON data
  • Creating a YAML data file
  • Using HTML5 data storage solutions
Subjects:
Developer Web
Software:
HTML XML CSS JSON YAML
Author:
Joseph Lowery

Integrating HTML5 form controls

HTML5 brought a lot of cool new toys to the table, but one area was especially welcome and needed and that's forms. There were numerous enhancements to form elements as part of the HTML5 specification, many of which have been implemented in modern browsers. In this lesson, we'll take a look at some of the most valuable changes and how you can best take advantage of them. I have open here the index.htm file from the chapter one 0103 folder of the exercise files.

As you can see there's a pretty basic form here I'll scroll down just a bit more asking for info from potential students. We'll use this to illustrate the various HTML5 attributes and input types. I also have the same page open in my code editor, so we can take a peek under the hood from time to time. Now let's head back to the browser, and I'm going to refresh the page to simulate loading it for the first time, and you'll notice that when I do, the cursor jumps into the first field, ready for entry.

This occurs because the name field has an autofocus attribute. Let me show you that in the code. I'm going to scroll down to where my form starts on line 39, and here in the input field, you see as the second to last attribute autofocus. Now, you'll also notice the place holder text, your full name. Let's head back to the browser and watch what happens when I start typing. Instantly, the placeholder text disappears.

Again, that's controlled by an HTML5 attribute called, naturally placeholder. The text that appears is the placeholder's value, you see it as the attribute just before auto-focus. Now, if I change the placeholder value, lets make it Full name please, save the file and then head back to the browser, when it's refreshed, you see the new placeholder icon.

Both autofocus and placeholder are relatively well-supported in modern browsers. Support for the other attributes used in the name form field required that you see here is a little spottier but it's getting better. Watch what happens when I click submit without entering a name in the browser. We'll go back and just click submit I get a small pop-up asking me to fill out the field. Unfortunately, there's not a lot of controlled for the required validation. You really can't change the message.

And styling is pretty difficult as well. There are numerous other HTML5 attributes, but most don't have enough browser traction yet to be impactful. Lets turn our attention to the new HTML5 input types, there are a slew of new input types, 13 in all. Most of them apply to what are basically text input fields. I've got a number of examples in our form, first there's the email field. Now if we go back to the code and take a look at line 46 here.

You'll notice the type is set to email. In standard desktop browsers, you won't really see much in the way of change, but mobile browsers are a different animal altogether. Let's switch to an iPhone emulator, so you can see a real difference. Now, I have the page open in my emulator and I'm going to scroll down a little bit to where my form is. The form has not been optimized for responsive design, but it's close enough for government workers as my dad used to say. You'll get the idea. Now if I tap into the name field, there's a standard keyboard.

Now let me just enter my name. Click done, and let's go to the email field. The difference is subtle, but it's there. And now I have both an at symbol and a period available to me. Essential characters for any email address. Input types go a long way towards enhancing user experience. Now let me show you what I consider is a major ux enhancement. Let me just go ahead and click done here. And this time, I'll click into the cell phone field.

Now, I've got a numeric keyboard. Perfect for quickly entering phone numbers. This is because the field's input type is set to tel, t e l. As you can see the code on line 50. Now the enhancements aren't just restricted to different types of keyboards. Let's go into the birthday field, and now we have a very lovely date picker, so I can scroll down to something closer to my birthday, pretty quickly, let's see where I end up going. Good enough.

And in addition to an actual date picker, we have the range input type. Which you see here for the number of years for art study is set up as a slider. Now I don't have this set up to show the value chosen. That's one of the problems with the range input type, as implemented. You can overcome that by adding some JavaScript in, but for now, if you're using the standard range input type, you want to do so in situations where an exact value is not imperative, input types like date and range are still in development on the browser front, and you'll see a lot of different implementations of them.

For the time being, you need to rely on added JavaScript coding to make these HTML file form elements fully functional across the board. And if you need to implement range element right away. Check out my course, HTML5 Projects engaging e commerce.

There are currently no FAQs about Working with Data on the Web.

 
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.

* Estimated file size

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 Working with Data on the Web.

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 ?

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 preferences from 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.

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your lynda.com subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

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.