A Look Into HTML5 Forms Input Types: Date, Color and Range

Forms are found everywhere on websites. Facebook, Twitter, Google — just to name a few — require us to log into or register to the site through a form, in fact we also use a form to tweet and updating status in social sites. In short, the form is a very important part to be able to interact to a website.
A web form is built with inputs, in the past, we only have a few option for the input types; such as text, password, radio, checkbox and submit. Now, HTML5 comes with great improvements and introduces many new input types in the spec.
So, in this post we will dig into some of the new interesting pieces from the HTML5 Forms that we think you should try them on; let’s check them out.

Date Picker

The first thing we would like to take a look at is the date picker. Selecting date is a common thing you may find in registration form, particularly in some sites or application like flight and hotel booking.
There are many JavaScript Libraries to create date picker. Now, we can also create one in much easier way with HTML5 input date, as follows;
<input type="date">
The date picker in HTML5 basically works very similar to how the JavaScript Libraries did; when we focus on the field a calendar will pop out, and then we can navigate through the months and years to select the date.
However, each browsers that currently support the date input type namely Chrome, Opera, and Safari display this input type a bit differently which potentially lead to inconsistency issue in the user experience, and here is how it looks like;
Some notable differences you can see at a glance from the above screenshot; the Opera used the English three-letter abbreviation for the days name — Sun, Mon, Thu, and so on, while the Chrome used my local language, the Safari — on the other hand — works rather odd, it is not showing a calendar at all.
There are also some new input types to select date or time more specifically; month, week, time, datetime and datetime-local, which we are sure that the keyword itself is quite desctiptive to tell what it does.
<input type="month">
<input type="week">
<input type="time">
<input type="datetime">
<input type="datetime-local">
You can view all of them in action from the link below, but make sure you view it in Opera 11 and above, since, at the of the writing, it is the only browser that support all of those input types.

Color Picker

Color picker is often needed in certain web-based application, such as this CSS3 gradient generator, but all this time web developers also still rely on a JavaScript Library, such as jsColor, to do the job. But now we can create a native-browser color picker with HTML5 color input type;
<input type="color">
Once again, the browsers, in this case the Chrome and Opera, render this input type slightly different;
The Opera firstly display the basic color option upon the click as well as the hex format of the current picked color in a dropdown, while the Chrome will directly pop up the color palette in a new window when clicked.
Furthermore, we can also set the default color with the value attribute, as follows;
<input type="color" value="#ff0000">
That way, when it is viewed in the unsupported browsers, the input will degrade in a text field and the default value will be visible that can give a sort of hint for users what should be entered in the field.

Display the Color Value

Rather than opening Photoshop just to copy the hex color format, you can actually create a simple tool upon this input type to do the job, since the generated color is already in hexadecimal this would be really easy;
First, we add id colorpicker to the input and we also add an empty div with id hexcolor next to it to contain the value.
<input type="color" id="colorpicker" name="color" value="#ff0000"> <div id="hexcolor"></div>
We need the jQuery linked in the head of our document. Then we store the color value and the newly added div in a variable, like so;
var color   = $('#colorpicker').val();
 hexcolor = $('#hexcolor');
Get the initial value from the #colorpicker;
hexcolor.html(color);
…and lastly change the value when the picked color is changed as well;
$('#colorpicker').on('change', function() {
    hexcolor.html(this.value);
});
That’s it; now let’s view it in action.

Category

10 Resources for Designers and Developers 11 Big Tech Trends You'll See in 2013 12/12/12 56 Mashable Stories 60 second Video how to keep laptop work well 70th Golden Globes ads adsense Adsense Tips Advertising AdWords Amazon Android AngryBird Apple Apple's 2012 Year in Review Apps Apps to Spice Up Your Sex Life article Barack Obama Benefits of a Job Search Community Bill Clinton Bing Bitcoins Blackberry blogging blogging secret blogging tools book Book Review; Content Marketing for Dummies Building an Email List Business News Business tips Campaign Websites Celebrities Charlie the Unicorn Chrome Content Spoiler With Simple Animation Creative Ways to Use Your Favorite Running App CSS Design Competition for Kids Digital Media Resources dnt do not track download drive traffic Dropbox Tools e-commerce ebay Effects Social Networks email enterprenour blog Entertainment Expired Domain Business Facebook facebook hacker File Management Film Firefox for Andoid Friends Sex App Gadget Games Geeks george bush george w. bush gmail golden globes Google Google + (plus) Google API Google Capture Google Trends Google Wallet Google XPhone Guest Blog Post Guest Posting Guide to Super Bowl 2013 Betting Guide To: WordPress Development With Microsoft WebMatrix gyroscopes for optical image stabilization history Hopper DVR Horde Hot Advertising Trends of 2012 How to Backup Your Skype Chat & Audio Conversations Online With Simkl html Html 5 HTML Tool hulu Hurricane Sandy instagram's new policy internet Internet Marketing Internet users iOs 6 iPad iPhone Kim Dotcom Laptop LES link building Linkedin Malware Marketing predictions 2013 marketing tips Microsoft Microsoft Surface Pro Mobile App Websites Mobile phone Mobile web Mobile web design monetizing blog money online Motorola Music NBA Negative Target Fixation New year's resolution News nostalgia Notebook Obama Online Education Online Payment Online Stores Palestinian Statehood parental apps PC Jobs Photoshop for Retina Displays Pics Pinterest Plugin porn in vine President Obama's Speech at Vigil for Newtown Victims Promoting Yourself Via Print Publisher Radio Station Review Romsey RoundCube. mail. cpanel Russian Plane Crash Video Search engine security seff identity security SEO SEO 2013 Shop For Geeky Gifts Smartphone-Enabled Website social media Social Networks Social Sites for Families Softaculous software Spam SquirrelMail superbowl 2013 Tablet Teaching Tool Tech Technology Television The Most Reputable Company in U.S. Things I Learned About Tech in 2012 tips Tools twitter latest U.S. UN Vote Universe Unlocked iPhone 5 in the U.S. upgrade script US election US president vote us presidents video Video Conferencing App for Mac Video Marketing Videos Watercooler Ways to Stay Creative While Working From Home Waze web Web design trend 2013 web traffic webtools Wedding What Is Pinterest? White House Why You Should Say No To Multitasking Wi-Fi Smart Scale windows 7 Windows 8 Windows 8 Review Windows RT Review Wirelessly Monitors Your Driving with Dash WomenWeb Wordpress Wordpress Plugin Working From Home writing web Xbox Yahoo YouTube Favorite YouTube Updates