sendesignz

Creating User Friendly Web Form with HTML5

You probably designed a complicated user interface and you know that the basic HTML is limited. You may stuck using text fields, select menus, radio buttons, checkboxes, and so on. In this tutorial I will show you how to build a user friendly web form using some new  form types and we'll also implement auto focusing and placeholder text in HTML5.


Modern Browsers can use these new fields to display better controls to the user without the need for JavaScript. Mobile devices and virtual keyboards for tablets and touch screens can use the field types to display different keyboard layouts. For example, the iPhone's Mobile Safari browser displays alternate keyboard layouts when the user is entering data into the URL and email types, making special characters like @ , . , : , and / easily accessible.

Not like traditional doctype the HTML5 doctype is very simple and easy to remember

 

<!DOCTYPE html>

Place that at the top of the document, and you're using HTML5. Of course, you can't use any of the new HTML5 elements that your target browsers don't yet support, but your document will validate as HTML5.

Final Output



HTML

<form id="create_account" action="/signup" method="post">

<fieldset id="signup">

<legend>Create New Account</legend>

<ul>

<li>

<label for="first_name">First Name</label>

<input id="first_name" type="text"

autofocus="true"

name="first_name" placeholder="'John'" >

</li>

<li>

<label for="last_name">Last Name</label>

<input id="last_name" type="text"

name="last_name" placeholder="'Smith'" >

</li>

<li>

<label for="email">Email</label>

<input id="email" type="email"

name="email" placeholder="Email address" >

</li>

<li>

<label for="url">Website</label>

<input id="url" type="url"

name="url" placeholder="www.example.com">

</li>

<li>

<label for="password">Password</label>

<input id="password" type="password" name="password" value=""

autocomplete="off" placeholder="8-10 characters" />

</li>

<li>

<label for="password_confirmation">Password Confirmation</label>

<input id="password_confirmation" type="password"

name="password_confirmation" value=""

autocomplete="off" placeholder="Type your password again" />

</li>

<li><input type="submit" value="Sign Up"></li>

</ul>

</fieldset>

</form>


We are making this form with labels.This is essential when creating accessible forms. The 'for' attribute of the label references the id of its associated form element. This helps screen readers identify fields on a page. I used <ul> to reduce the complex tables or div structures.

Fieldset

The fieldset element defines a form control group. By grouping related form controls, you can divide a form into smaller, more manageable parts, improving the usability disaster that can strike when confronting users with too many form controls.

Email

 

The HTML5 specification says that the email input type is designed to hold either a single email address or an email address list, so that’s the perfect candidate for our email field.

<label for="email">Email contact</label>

<input type="email" name="email" id="email">


Mobile devices get the most benefit from this type of form field, because the virtual keyboard layouts change to make entering email addresses easier.

URL

There's a field type designed to handle URLs too. This one is especially nice if your visitor uses an iPhone, because it displays a different keyboard layout, displaying helper buttons for quickly entering web addresses, similar to the keyboard displayed when entering a URL into Mobile Safari’s address bar. 

<label for="url">Website</label>

<input type="url" name="url" id="url">

Autofocus

You can really speed up data entry if you place the user's cursor in the first field on the form when they load the page. Now HTML5 provides this capability as part of the language.
you can  add the autofocus attribute to any form field. I have added this in my firstname text field.

<label for="first_name">First Name</label>

<input id="first_name" type="text"  name="first_name"  autofocus="true" >



PlaceHolder

Placeholder text provides users with instructions on how they should fill in the fields.
To add placeholder text, you just add the placeholder attribute to each input field. Link this:

<input id="first_name" type="text"  name="first_name" placeholder="'John'" >
 

 

Preventing Autocompletion

HTML5 introduces an autocomplete attribute that tells web browsers that they should not attempt to automatically fill in data for the field. Some browsers remember data that users have previously typed in, and in some cases, we want to tell the browsers that we'd rather not let users do that. We have added the attribute to the password fields on this form.

<label for="password">Password</label>

<input id="password" type="password" name="password" value="" autocomplete="off" />

CSS

body{

font-family:Verdana, Geneva, sans-serif;

font-size:12px;

color:#000;

}

fieldset{

width: 216px;

}

fieldset ul{

list-style: none;

padding:0;

margin:2px;

}

fieldset ul li{

margin:0 0 9px 0;

padding:0;

}

/* Make inputs go to their own line */

fieldset input{

display:block;

}


Now only Safari, Opera, and Chrome will have helpful text inside the form fields. Firefox and Internet Explorer will not support the placeholder.

Leave your comments

Post comment as a guest

0
terms and condition.

People in this conversation

  • I was actually looking at this card last night, after reading this and the footage, i will be purchasing once i receive my check from work!

    0 Like Short URL:
  • It is important to consider that forms can make a website usable or unusable, because they can stand in the way of the user achieving their goal or simplify the process for both the business and the user. Its good article.

    0 Like Short URL:
  • Hey Nice Blog.Thank you for the valuable review.Will surely follow it.<br /> investment newsletter

    0 Like Short URL:
  • Guest (kevinanchi)

    Thank you for sharing to us.there are many person searching about that now they will find enough resources by your post.I would like to join your blog anyway so please continue sharing with us<br />http://free--creditscore.com

    1 Like Short URL:
  • Guest (Free Credit Score)

    Thank you for sharing to us.there are many person searching about that now they will find enough resources by your post.I would like to join your blog anyway so please continue sharing with us

    1 Like Short URL: