Digg.com is one of the most popular social networking sites, allowing you to discover and share the content all over the web. In this tutorial we are going to simulate their signup form, with unique features such as their dynamic tooltips that give you a hint on each field that is to be filled. The same approach will be adopted for displaying validation messages.
Before we get started, you may like to view a demo of the end result.
How this form works?
When an input field receives focus, a tooltip with a small blue icon is shown under it. On the other hand, if validation fails, an error message is shown in the same place. Both cases are shown on the screenshot below.
Let’s start
We are not going to recreate the entire form, but rather a few fields just to see how it works. Let’s take a closer look at the code sample. Each field row has a label, an input field, an info message and a validation message. Below you can see the HTML structure and CSS classes.
Note that, by default, both info and validation messages are hidden, which is set in tooltipContainer CSS class.
body{ font-family:Arial, Sans-Serif; font-size:83%; } .formContainer { background-color: #F5EFC9; border:none; padding:30px; } .formContainer h3 { margin:0px; padding:0px 0px 10px 0px; font-size:135%; } .rowContainer { width:100%; overflow:hidden; padding-bottom:5px; height:34px; } .rowContainer label { width:140px; float:left; color: #758656; font-weight:bold; } .rowContainer input[type=“text”] { width:200px; } .tooltipContainer { height:16px; font-size:11px; color: #666666; display:none; float:none; background-repeat:no-repeat; background-position:left center; padding:0px 20px; } .info { background-image:url(‘info.gif’); } .error { background-image:url(‘error.gif’); }
Now let’s add some interactivity
So far we have a static HTML structure and hidden messages waiting to be shown. We have to write a few lines of code to make them appear/disappear. Of course, this can be accomplished by pure JavaScript, but let’s involve jQuery. The reason for this is quite simple – less coding.
Like I mentioned at the beginning of this tutorial, an info tooltip should be shown each time an input field gets focus and hidden when it loses it. Turn this into jQuery code and you get this:
$(document).ready(function(){
$(”.formContainer input[type=text]”).focus(function(){
$(this).parent().find(”.info”).css(“display”, “block”);
}).blur(function(){
$(this).parent().find(”.info”).css(“display”, “none”);
});
});
Simple, isn’t it? Now, let’s see how to handle validation messages. We are going to create fake validation just for the purpose of this tutorial. We’ll use jQuery again.
function validateForm()
{
$(”.formContainer input[type=text]”).each(function(){
var text = $(this).attr(“value”);
if (text == “”)
{
$(this).parent().find(”.error”).css(“display”, “block”);
}
});
}
In essence, what the code above does is it shows a validation message for each field that the user hasn’t entered text in. Please keep in mind that this is not real validation, it just simulates what would happen if validation failed. You would have to implement your own logic, eg. check for mandatory fields, email address format and so on.
Ok, after pressing the sign-in button, validation messages will be shown. Signup form on Digg.com hides these messages and replaces them with info tooltips when the user starts to type. So we are missing a piece of code that will hide validation messages that were previously shown.
Let’s do it the dirty way. We’ll extend our jQuery code that controls the appearance of tooltips to hide corresponding validation messages each time an input field gets focus.
$(document).ready(function(){
$(”.formContainer input[type=text]”).focus(function(){
$(this).parent().find(”.error”).css(“display”, “none”);
$(this).parent().find(”.info”).css(“display”, “block”);
}).blur(function(){
$(this).parent().find(”.info”).css(“display”, “none”);
});
});
This way we have recreated the Digg.com signup form. You can check out live demo or download full source code.
Conclusion
You saw how to recreate the Digg.com signup form with simple CSS and just a few lines of jQuery code. However, there are a few pieces of advice I’d like to give you:
- Do not overwork the form – there is really no need for a tooltip that says “Enter your first and last name in the field that says First and Last name”. Instead, you can provide a message that shows a constraint, for example “Maximum 35 characters”.
- Use tooltip/validation color other that text color – try hitting the “Continue” button on Digg.com signup form before entering any text. The form becomes very hard to read and it’s difficult to distinguish where one field ends and the next begins.

Comments & Discussion
75 Comments
Pingback: C4 » Blog Archive » JQuery plugins. part 2
Pingback: 10+ JQuery tutorials for working with HTML forms | Vectordump
Pingback: 25 jQuery Tutorials for Creating and Working with Forms « Freelance Web Designer from Hyderabad, India.
Pingback: 25 jQuery Tutorials for Creating and Working with Forms | Son Of Byte - Web Design & Development
Pingback: フォームで使えるjQueryテクニック集「10+ JQuery tutorials for working with HTML forms」 | WebLab
Pingback: PHP Forms with jQuery Validation Tutorials | Geekatude.com
Pingback: Digg风格的jQuery注册表格
Pingback: 15 Essential Tutorials to Spice Up your Web Forms | Creative Repository
Pingback: 55 jQuery Form Plugins To Download And Use | Design your way
Pingback: 55 jQuery Form Plugins To Download And Use « qeqnes | Designing. jQuery, Ajax, PHP, MySQL and Templates
Pingback: 19 Unique jQuery Tutorials for Web Developers | Tutorials
Pingback: 19 Unique jQuery Tutorials for Web Developers « Tutorials Categorized
Pingback: UK Web Design Now! » Post Topic » 19 Unique jQuery Tutorials for Web Developers
Pingback: Japan – News And Articles » Blog Archive » ウェブ開発者|チュートリアル19ユニークjQueryのチュートリアル
Pingback: 19 Unique jQuery Tutorials for Web Developers » iconnice
Pingback: 彼岸(Into the wild) » Blog Archive » 19 Unique jQuery Tutorials for Web Developers
Pingback: 20 great tutorials for learning jQuery for web web developers « Web Design Scoop a web design development and technology blog
Pingback: jQuery Tutorials για Web Developers « Web Resources
Pingback: 19个网站开发jQuery教程,效果都特别好 | 设计之家
Pingback: 19 Unique jQuery Tutorials for Web Developers | Technotipz
Pingback: 19 Unique jQuery Tutorials for Web Developers | YuupLoad
Pingback: 10 jQuery Slider Techniques and Plugins | StarWebSoft Blog - Website Design & Development, SEO Service, Online Marketing
Pingback: Top 10 jQuery Form Selection | jQuery4u
Pingback: » 65 jQuery Tutorials To Help You Customize Your Site
Pingback: bagel cafe » ぐりぐり動かせるデザインも素敵な、jQueryチュートリアル65選
Pingback: 12 Useful JQuery Tutorials and Techniques for Web Developers | TeginGraphics
Pingback: 20 Great jQuery Tutorials For Website Designers And Developers | DESIGNSBYTES
Pingback: Very Classic jQuery Form Plugins For Use | Free download softwares, music, wordpress template, joomla template, Jquery tools and tips, Beauty tips, Free online video..
Pingback: 19 Unique jQuery Tutorials for Web Developers
Pingback: 19款独一无二的jQuery教程 For Webeeeeer | QFisH
Pingback: 10+ JQuery tutorials for working with HTML forms | CatsWhoCode.com
Pingback: Latest jQuery Plugins Write Less Do More Episode - 2
Pingback: 45 jQuery Plugins And Tutorials To Enhance Your Forms | Free and Useful Online Resources for Designers and Developers
Pingback: 45 jQuery Plugins And Tutorials To Enhance Your Forms
Pingback: Techniques for Constructing Usable Registration Forms | Tips
Pingback: Grafix 365 » Techniques for Constructing Usable Registration Forms
Pingback: Techniques for Constructing Usable Registration Forms | Bitmag
Pingback: Techniques for Constructing Usable Registration Forms
Pingback: Techniques for Constructing Usable Registration Forms | Momoto Design
Pingback: Techniques for Constructing Usable Registration Forms | NuzaRazzi
Pingback: Techniques for Constructing Usable Registration Forms | CS5 Design
Pingback: 【资讯】201155 个 jQuery 表单插件 | 天天生活
Pingback: 25 jQuery Tutorials for Creating and Working with Forms | Lake of Web
Pingback: 55 jQuery Form Plugins To Download And Use « RPL Class
Pingback: 8 Registration and Sign up form Tutorials