<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Web International Awards &#187; design</title>
	<atom:link href="http://www.webia.info/category/articles/design/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.webia.info</link>
	<description></description>
	<lastBuildDate>Tue, 09 Aug 2011 15:42:18 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Always ask the right questions in your webforms!</title>
		<link>http://www.webia.info/articles/usability/always-ask-the-right-questions-in-your-webforms/</link>
		<comments>http://www.webia.info/articles/usability/always-ask-the-right-questions-in-your-webforms/#comments</comments>
		<pubDate>Fri, 18 Feb 2011 12:00:38 +0000</pubDate>
		<dc:creator>Bogdan Pop</dc:creator>
				<category><![CDATA[design]]></category>
		<category><![CDATA[usability]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[question]]></category>
		<category><![CDATA[questions]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[ui]]></category>
		<category><![CDATA[user]]></category>
		<category><![CDATA[webform]]></category>

		<guid isPermaLink="false">http://www.webia.info/?p=1836</guid>
		<description><![CDATA[
Before diving in into the issue, I'd like to point out this great article over Usability Post that describes a delicate issue: using verbs on labels and buttons. Applying the same idea, it's best if you asked the right questions too. You wouldn't want to confuse the users and give them headaches while answering your [...]]]></description>
			<content:encoded><![CDATA[<p>
Before diving in into the issue, I'd like to point out this great article over Usability Post that describes a delicate issue: <a href="http://www.usabilitypost.com/2008/08/30/usability-tip-use-verbs-as-labels-on-buttons/" target="_new">using verbs on labels and buttons</a>. Applying the same idea, it's best if you asked the right questions too. You wouldn't want to confuse the users and give them headaches while answering your questions. This matters on each question of you form, from the most complicated to the simple captcha questions.
</p>
<p>
So, don't ask if I am human and expect an answer other than yes or no. SDUIHA or jgV54D is not a valid answer if you asked me if I were human. Imagine you asked a Japanese what was their name and they replied Sushi. Now that wouldn't be a great start, would it? So to wrap things up, never ask anyone if they're human and expect gibberish in return. One bad example from <a href="http://www.hongkiat.com/blog/" target="_new">Hongkiat</a> is just below.
</p>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2011/02/hongkiat_bad_form_question.jpg" title="Form asking if I were human and expecting gibberish in return instead of yes or no"><img src="http://www.webia.info/wp-content/uploads/2011/02/hongkiat_bad_form_question.jpg" alt="Form asking if I were human and expecting gibberish in return instead of yes or no" /></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.webia.info/articles/usability/always-ask-the-right-questions-in-your-webforms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Impressive web forms. From coding to validation!</title>
		<link>http://www.webia.info/articles/usability/impressive-web-forms-from-coding-to-validation/</link>
		<comments>http://www.webia.info/articles/usability/impressive-web-forms-from-coding-to-validation/#comments</comments>
		<pubDate>Tue, 23 Mar 2010 17:37:00 +0000</pubDate>
		<dc:creator>Bogdan Pop</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[layout]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[usability]]></category>
		<category><![CDATA[client]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[experience]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[validation]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://www.webia.info/?p=1175</guid>
		<description><![CDATA[
Preview of the tutorial

Quite some time ago I have published the first part of this series. Today I'll tackle coding a good webform, styling it, client-side and server-side validating. The first part of the tutorial was extremely popular, and that's why I chose to merge parts two and three, which anyway are closely related. 


PS: [...]]]></description>
			<content:encoded><![CDATA[<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2010/03/webraptor_form_validation.jpg" title="Screenshot of WebRaptor's request quote form"><img src="http://www.webia.info/wp-content/uploads/2010/03/webraptor_form_validation.jpg" alt="Screenshot of WebRaptor's request quote form" /></a></p>
<h2>Preview of the tutorial</h2>
<p>
Quite some time ago I have published the first part of this series. Today I'll tackle coding a good webform, styling it, client-side and server-side validating. The <a href="http://www.webia.info/articles/usability/forms-cant-live-with-them-cant-live-without-them/" target="_new">first part</a> of the tutorial was extremely popular, and that's why I chose to merge parts two and three, which anyway are closely related. 
</p>
<p>
PS: You'll need some patience digesting this tutorial as it turned out to be really complex.
</p>
<p>
The code I am about to present here is the one that has been used in our contact and request quote forms from our newly released <a href="http://www.webraptor.eu" target="_new">web development website</a>, just as the <a href="http://www.webia.info/articles/tutorials/make-your-own-jquery-slider-using-xml/" target="_self">jQuery slider tutorial</a> published a few weeks ago was used in our portfolio section.
</p>
<h2>Getting dirty with xhtml</h2>
<p>
I am not going to code all different label positioning options presented in the first article (inline, left-aligned, right-aligned, top-aligned). The one I chose for our website and will be showcased over here is the one with top-aligned labels. 
</p>
<p>
I chose top-aligned labels because the page layout where the form is implemented doesn't allow a lot of horizontal space. The bonus was that potential clients could process it fast. Being a form with just a couple of fields, the vertical space required by the form is decent.
</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&lt;form action=&quot;contact-us-process.php&quot; method=&quot;post&quot; accept-charset=&quot;utf-8&quot; id=&quot;contactform&quot;&gt;
	&lt;fieldset&gt;
		&lt;label for=&quot;name&quot;&gt;Full name : &lt;/label&gt;
		&lt;div class=&quot;field&quot;&gt;
			&lt;input type=&quot;text&quot; name=&quot;name&quot; value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?=</span><span style="color: #000088;">$name</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; id=&quot;name&quot; class=&quot;v-required&quot; /&gt;
		&lt;/div&gt;
		&lt;label for=&quot;email&quot;&gt;Email : &lt;/label&gt;
		&lt;div class=&quot;field&quot;&gt;
			&lt;input type=&quot;test&quot; name=&quot;email&quot; value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?=</span><span style="color: #000088;">$email</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; id=&quot;email&quot; class=&quot;v-required v-email&quot; /&gt;
		&lt;/div&gt;
		&lt;label for=&quot;phone&quot;&gt;Phone : &lt;/label&gt;
		&lt;div class=&quot;field&quot;&gt;
			&lt;input type=&quot;text&quot; name=&quot;phone&quot; value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?=</span><span style="color: #000088;">$phone</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; id=&quot;phone&quot; class=&quot;v-required v-digits&quot; /&gt;
		&lt;/div&gt;
		&lt;label for=&quot;message&quot;&gt;Message : &lt;/label&gt;
		&lt;div class=&quot;field&quot;&gt;
			&lt;textarea name=&quot;message&quot; class=&quot;v-required&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?=</span><span style="color: #000088;">$message</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/textarea&gt;
		&lt;/div&gt;
		&lt;label for=&quot;security&quot;&gt;One plus two: &lt;/label&gt;
		&lt;div class=&quot;field last&quot;&gt;
			&lt;input type=&quot;text&quot; name=&quot;security&quot; value=&quot;&quot; id=&quot;security&quot; class=&quot;v-required v-security&quot;/&gt;
			&lt;small&gt;Sorry, we asked as we do not like spam&lt;/small&gt;
		&lt;/div&gt;
		&lt;span class=&quot;clear&quot;&gt;&amp;nsbp;&lt;/span&gt;
		&lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Send the message&quot; id=&quot;submit&quot; class=&quot;button all-rounded&quot; /&gt;
	&lt;/fieldset&gt;
&lt;/form&gt;</pre></td></tr></table></div>



<p>
As you can see, all elements are wrapped inside a singular <em>fieldset</em>, and each input field is wrapped inside a <em>div.field</em> block element. The reason why all input areas are wrapped inside a div is because I wanted to add that nice border to each input element, border which needed to be consistent through input fields, textareas, select elements and more. As you'll see in a couple of minutes, the styling is achieved with just a few bits of CSS.
</p>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2010/03/webraptor_form_validation_close_up.jpg" title="Close up shot: fancy borders around input fields"><img src="http://www.webia.info/wp-content/uploads/2010/03/webraptor_form_validation_close_up.jpg" alt="Close up shot: fancy borders around input fields" /></a></p>
<p>
You may also ask what's up with the bits of php coding that are embedded in the input elements &#8212; the code that's emphasized above. You'll find out soon enough when we reach the final point of this tutorial: server-side validation.
</p>
<h2>The CSS</h2>
<p>
Without any CSS the form described above would look terrible, so let's see what we can do to make it shine!
</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#contactform</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">1em</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#contactform</span> label<span style="color: #00AA00;">,</span>
<span style="color: #cc00cc;">#contactform</span> input<span style="color: #00AA00;">,</span>
<span style="color: #cc00cc;">#contactform</span> select<span style="color: #00AA00;">,</span>
<span style="color: #cc00cc;">#contactform</span> textarea<span style="color: #00AA00;">,</span>
<span style="color: #cc00cc;">#contactform</span> <span style="color: #6666ff;">.field</span>	<span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">clear</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#contactform</span> <span style="color: #6666ff;">.field</span>	<span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">0.5em</span><span style="color: #00AA00;">;</span> border-radius<span style="color: #00AA00;">:</span><span style="color: #933;">0.4em</span><span style="color: #00AA00;">;</span> -moz-border-radius<span style="color: #00AA00;">:</span><span style="color: #933;">0.4em</span><span style="color: #00AA00;">;</span> -webkit-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">0.4em</span><span style="color: #00AA00;">;</span> 
					 <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">228</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">228</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">228</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span>rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">51</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">51</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">51</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0.1</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#contactform</span> <span style="color: #6666ff;">.field</span> span<span style="color: #6666ff;">.error</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#FF0000</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">text-indent</span><span style="color: #00AA00;">:</span><span style="color: #933;">0.5em</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#contactform</span> <span style="color: #6666ff;">.field</span> span<span style="color: #6666ff;">.ok</span>	<span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#339933</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">text-indent</span><span style="color: #00AA00;">:</span><span style="color: #933;">0.5em</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#contactform</span> label <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">2em</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#contactform</span> input <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">20em</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">2em</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">2em</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#contactform</span> select <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">20.5em</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#contactform</span> textarea <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">30em</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">8em</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">2em</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#contactform</span> input<span style="color: #00AA00;">,</span>
<span style="color: #cc00cc;">#contactform</span> textarea <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#333333</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">2em</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding-left</span><span style="color: #00AA00;">:</span><span style="color: #933;">0.5em</span><span style="color: #00AA00;">;</span> 
						<span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> <span style="color: #ff0000;">&quot;Lucida Grande&quot;</span><span style="color: #00AA00;">,</span> <span style="color: #ff0000;">&quot;Lucida Sans Unicode&quot;</span><span style="color: #00AA00;">,</span> <span style="color: #ff0000;">&quot;Lucida Sans&quot;</span><span style="color: #00AA00;">,</span> <span style="color: #ff0000;">&quot;DejaVu Sans&quot;</span><span style="color: #00AA00;">,</span> <span style="color: #ff0000;">&quot;Bitstream Vera Sans&quot;</span><span style="color: #00AA00;">,</span> <span style="color: #ff0000;">&quot;Liberation Sans&quot;</span><span style="color: #00AA00;">,</span> Verdana<span style="color: #00AA00;">,</span> <span style="color: #ff0000;">&quot;Verdana Ref&quot;</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#contactform</span> small <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">clear</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#contactform</span> <span style="color: #6666ff;">.last</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin-bottom</span><span style="color: #00AA00;">:</span><span style="color: #933;">2em</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>



<p>
As we have a top-aligned form, all elements should flow beneath the one before it. We do this by floating all of them to the left and clearing the left side (lines 2-6). The <em>field</em> class is applied to divs that wrap all input elements. The one I said will be used to add a nice consistent border to input elements throughout the webform.
</p>
<p>
On line 7 we add padding to the <em>field</em> element, round the corners (if browsers support it), then set a transparent background, with fallback for browsers which do not support RGBA. I have used <em>background</em> instead of <em>background-color</em> because the later won't make the fallback RGB work.
</p>
<p>
The two <em>span</em> elements styled on lines 9 and 10 will be used for inline validation. Error messages will have the <em>error</em> class while confirmation messages will have the <em>ok</em> class. We need some space between different label &#038; input groups in the form, that's why there's a top margin for each label. 
</p>
<p>
On lines 12 to 14 we set the widths and heights of the input elements, while on lines 15 and 16 we style the appearance of basic input fields and textareas. The font-family is inserted here because textareas seem to have a mind of their own, and using em sizing will trigger unexpected results because of the font used. Choose a font that's different than your body's font and the textarea, though having the same specified size as a regular input field, will not have the same width as an input field.
</p>
<span id="more-1175"></span>
<h2>Done styling. Let's validate data!</h2>
<p>
There's two ways we can validate data on a webform. One is by using client-side technologies, mainly JavaScript, and the other by using server-side technologies, be it PHP, ASP, Ruby or anything else you're using for your project. If you were thinking not to validate on the server-side if you have client-side validation, think again, because people could have javascript turned off and send malicious data to your server and databases.
</p>
<p>
This is why server-side validation is mandatory and client-side validation is optional, but can be used to really enhance the experience of your website's visitors.
</p>
<h2>Client side validation</h2>
<p>
In order to know how to validate each field in our form, we need to add specific classes to each one. <em>v-required</em> stands for a required field, <em>v-digits</em> is used for fields that should accept only digits while <em>v-email</em> is used for fields that expect and email address.
</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;input type=&quot;text&quot; name=&quot;name&quot; value=&quot;&lt;?=$name?&gt;&quot; id=&quot;name&quot; class=&quot;v-required&quot; /&gt;
&lt;input type=&quot;test&quot; name=&quot;email&quot; value=&quot;&lt;?=$email?&gt;&quot; id=&quot;email&quot; class=&quot;v-required v-email&quot; /&gt;
&lt;input type=&quot;text&quot; name=&quot;phone&quot; value=&quot;&lt;?=$phone?&gt;&quot; id=&quot;phone&quot; class=&quot;v-required v-digits&quot; /&gt;</pre></td></tr></table></div>



<p>
As you can see, our input fields have different classes assigned for our javascript to know how to validate. We've also assigned a unique ID to our form to be able to use it within our javascript. The validation script will have two main functionalities, one which will validate data on the fly (while the user is typing it and moving from a field to the next one), and one that will validate data when the submit button is pressed.
</p>
<p>
I am also using a dirty little trick. The validation will look inside the form for <em>error</em> classes. That's why on page load I am going to add an error class to each field that's required. When the user will type inside the field, the error class will be removed. When there's no error classes, data is valid and we can send it to our server for processing.
</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#contactform input.v-required,#contactform textarea.v-required'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'rel'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'error'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>



<p>
Select elements have a value assigned by default, so they don't need specific validation.
</p>
<h2>On the fly client-side validation</h2>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#contactform input:not(.button), #contactform textarea, #contactform select'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">focusout</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
error <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
inputText <span style="color: #339933;">=</span> <span style="color: #3366CC;">''</span><span style="color: #339933;">;</span>
inputText <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// this works for inputs</span>
<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>inputText.<span style="color: #660066;">length</span><span style="color: #339933;">==</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> inputText <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// this works for textareas</span>
&nbsp;
classes <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'class'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
classesArray <span style="color: #339933;">=</span> classes.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">' '</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
$.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span>classesArray<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>index<span style="color: #339933;">,</span> value<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>value<span style="color: #339933;">==</span><span style="color: #3366CC;">'v-required'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&amp;&amp;</span><span style="color: #009900;">&#40;</span>inputText.<span style="color: #660066;">length</span><span style="color: #339933;">==</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&amp;&amp;</span><span style="color: #009900;">&#40;</span>error<span style="color: #339933;">==</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span><span style="color: #006600; font-style: italic;">// required field empty</span>
		error <span style="color: #339933;">=</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>value<span style="color: #339933;">==</span><span style="color: #3366CC;">'v-digits'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&amp;&amp;</span><span style="color: #009900;">&#40;</span>testDigits<span style="color: #009900;">&#40;</span>inputText<span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&amp;&amp;</span><span style="color: #009900;">&#40;</span>error<span style="color: #339933;">==</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span> <span style="color: #006600; font-style: italic;">// field needs to be digits only</span>
		error <span style="color: #339933;">=</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>value<span style="color: #339933;">==</span><span style="color: #3366CC;">'v-email'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&amp;&amp;</span><span style="color: #009900;">&#40;</span>testEmail<span style="color: #009900;">&#40;</span>inputText<span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&amp;&amp;</span><span style="color: #009900;">&#40;</span>error<span style="color: #339933;">==</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span> <span style="color: #006600; font-style: italic;">// field needs to be email format</span>
		error <span style="color: #339933;">=</span> <span style="color: #CC0000;">3</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>value<span style="color: #339933;">==</span><span style="color: #3366CC;">'v-url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&amp;&amp;</span><span style="color: #009900;">&#40;</span>testURL<span style="color: #009900;">&#40;</span>inputText<span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&amp;&amp;</span><span style="color: #009900;">&#40;</span>error<span style="color: #339933;">==</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span> <span style="color: #006600; font-style: italic;">// field needs to be URL format</span>
		error <span style="color: #339933;">=</span> <span style="color: #CC0000;">4</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>value<span style="color: #339933;">==</span><span style="color: #3366CC;">'v-security'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&amp;&amp;</span><span style="color: #009900;">&#40;</span>testSecurity<span style="color: #009900;">&#40;</span>inputText<span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&amp;&amp;</span><span style="color: #009900;">&#40;</span>error<span style="color: #339933;">==</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span> <span style="color: #006600; font-style: italic;">// field needs to be URL format</span>
		error <span style="color: #339933;">=</span> <span style="color: #CC0000;">5</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>error<span style="color: #339933;">&gt;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span><span style="color: #006600; font-style: italic;">// there's some errors</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>error<span style="color: #339933;">==</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> 
	<span style="color: #009900;">&#123;</span> 
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">next</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'span.error'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;?</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">next</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'span.ok'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;span class=&quot;error&quot;&gt;This is a required field&lt;/span&gt;'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">insertAfter</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'rel'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'error'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>error<span style="color: #339933;">==</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span> 
	<span style="color: #009900;">&#123;</span> 
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">next</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'span.error'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;?</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">next</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'span.ok'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;span class=&quot;error&quot;&gt;Digits only please&lt;/span&gt;'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">insertAfter</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'rel'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'error'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>error<span style="color: #339933;">==</span><span style="color: #CC0000;">3</span><span style="color: #009900;">&#41;</span> 
	<span style="color: #009900;">&#123;</span> 
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">next</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'span.error'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;?</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">next</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'span.ok'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;span class=&quot;error&quot;&gt;Invalid email&lt;/span&gt;'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">insertAfter</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'rel'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'error'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>error<span style="color: #339933;">==</span><span style="color: #CC0000;">4</span><span style="color: #009900;">&#41;</span> 
	<span style="color: #009900;">&#123;</span> 
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">next</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'span.error'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;?</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">next</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'span.ok'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;span class=&quot;error&quot;&gt;Invalid URL&lt;/span&gt;'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">insertAfter</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'rel'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'error'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>error<span style="color: #339933;">==</span><span style="color: #CC0000;">5</span><span style="color: #009900;">&#41;</span> 
	<span style="color: #009900;">&#123;</span> 
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">next</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'span.error'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;?</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">next</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'span.ok'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;span class=&quot;error&quot;&gt;Incorrect answer&lt;/span&gt;'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">insertAfter</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'rel'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'error'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000066; font-weight: bold;">else</span>
	<span style="color: #009900;">&#123;</span> 
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">next</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'span.error'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;?</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">next</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'span.ok'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;span class=&quot;error&quot;&gt;Unknown error&lt;/span&gt;'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">insertAfter</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'rel'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'error'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000066; font-weight: bold;">else</span>
<span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">next</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'span.error'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">next</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'span.ok'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;span class=&quot;ok&quot;&gt;Ok&lt;/span&gt;'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">insertAfter</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeAttr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'rel'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>



<p>
On the first line of the above code we identify all input elements in the form. The form has an submit button and we need to exclude it. Also, we're going to apply a certain behavior to the selected elements when the user focuses out of them.
</p>
<p>
On the second line we initialize a variable which we're going to use to track errors. 1 for required, 2 for digits and so on. On lines 3 to 5 we get the contents the user typed inside the element. As we won't know at runtime which type of element we are dealing with, we need to make sure we get the content properly. Hence the differentiation of textfields and textareas.
</p>
<p>
The next step (lines 7 and 8 ) is to get the classes of the element we're currently checking. Classes can be v-required, v-digits, v-email, v-url and alike. We split the classes and put them into an array. Then, we loop through each class and test accordingly (lines 9 to 30). Based on test results, we modify the <em>error</em> variable.
</p>
<p>
We then check if there's any errors reported. If there's no errors the code from lines 72 to 76 will make necessary adjustments to our html for the user to see the field was correctly filled. On the other hand, if there were errors reported, the code between lines 34 and 69 will check the actual error type and modify html accordingly. The user will know they've done wrong, and how they've done wrong.
</p>
<h2>Functions to extend the validation process</h2>
<p>
If you payed attention to the above code you've seen that there are some function calls, functions which are not defined. Therefor, we must declare a few functions before we try using this plugin. These functions are coming up next:
</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> testEmail<span style="color: #009900;">&#40;</span>value<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009966; font-style: italic;">/^((([a-z]|\d|[!#\$%&amp;'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&amp;'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i</span>.<span style="color: #660066;">test</span><span style="color: #009900;">&#40;</span>value<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> testURL<span style="color: #009900;">&#40;</span>value<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009966; font-style: italic;">/^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&amp;'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&amp;'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&amp;'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&amp;'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&amp;'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i</span>.<span style="color: #660066;">test</span><span style="color: #009900;">&#40;</span>value<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> testDigits<span style="color: #009900;">&#40;</span>value<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009966; font-style: italic;">/^\d+$/</span>.<span style="color: #660066;">test</span><span style="color: #009900;">&#40;</span>value<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> testSecurity<span style="color: #009900;">&#40;</span>value<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>value<span style="color: #339933;">==</span><span style="color: #CC0000;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">||</span><span style="color: #009900;">&#40;</span>value<span style="color: #339933;">==</span><span style="color: #3366CC;">'three'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">||</span><span style="color: #009900;">&#40;</span>value<span style="color: #339933;">==</span><span style="color: #3366CC;">'THREE'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>



<p>As their name suggest these functions test emails and URLs for validity, if a string contains only digits or if the security question was correctly answered.
</p>
<h2>Validation upon submit</h2>
<p>
We've seen how we validate data on the fly. Let's see how we validate data when the user clicks the submit button or presses enter.
</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#contactform'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">live</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'submit'</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#contactform input.button'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'disabled'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'disabled'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#contactform input.button'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Processing request'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		errors <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#contactform span.error'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'input[rel=error],textarea[rel=error],select[rel=error]'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			errors<span style="color: #339933;">++;</span> <span style="color: #006600; font-style: italic;">// count if there are errors</span>
				error <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> 
				inputText <span style="color: #339933;">=</span> <span style="color: #3366CC;">''</span><span style="color: #339933;">;</span>
				inputText <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// this works for inputs</span>
				<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>inputText.<span style="color: #660066;">length</span><span style="color: #339933;">==</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> inputText <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// this works for textareas</span>
&nbsp;
				classes <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'class'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				classesArray <span style="color: #339933;">=</span> classes.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">' '</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				$.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span>classesArray<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>index<span style="color: #339933;">,</span> value<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
					<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>value<span style="color: #339933;">==</span><span style="color: #3366CC;">'v-required'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&amp;&amp;</span><span style="color: #009900;">&#40;</span>inputText.<span style="color: #660066;">length</span><span style="color: #339933;">==</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&amp;&amp;</span><span style="color: #009900;">&#40;</span>error<span style="color: #339933;">==</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
					<span style="color: #009900;">&#123;</span><span style="color: #006600; font-style: italic;">// required field empty</span>
						error <span style="color: #339933;">=</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
					<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>value<span style="color: #339933;">==</span><span style="color: #3366CC;">'v-digits'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&amp;&amp;</span><span style="color: #009900;">&#40;</span>testDigits<span style="color: #009900;">&#40;</span>inputText<span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&amp;&amp;</span><span style="color: #009900;">&#40;</span>error<span style="color: #339933;">==</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
					<span style="color: #009900;">&#123;</span> <span style="color: #006600; font-style: italic;">// field needs to be digits only</span>
						error <span style="color: #339933;">=</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
					<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>value<span style="color: #339933;">==</span><span style="color: #3366CC;">'v-email'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&amp;&amp;</span><span style="color: #009900;">&#40;</span>testEmail<span style="color: #009900;">&#40;</span>inputText<span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&amp;&amp;</span><span style="color: #009900;">&#40;</span>error<span style="color: #339933;">==</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
					<span style="color: #009900;">&#123;</span> <span style="color: #006600; font-style: italic;">// field needs to be email format</span>
						error <span style="color: #339933;">=</span> <span style="color: #CC0000;">3</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
					<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>value<span style="color: #339933;">==</span><span style="color: #3366CC;">'v-url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&amp;&amp;</span><span style="color: #009900;">&#40;</span>testURL<span style="color: #009900;">&#40;</span>inputText<span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&amp;&amp;</span><span style="color: #009900;">&#40;</span>error<span style="color: #339933;">==</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
					<span style="color: #009900;">&#123;</span> <span style="color: #006600; font-style: italic;">// field needs to be URL format</span>
						error <span style="color: #339933;">=</span> <span style="color: #CC0000;">4</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
					<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>value<span style="color: #339933;">==</span><span style="color: #3366CC;">'v-security'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&amp;&amp;</span><span style="color: #009900;">&#40;</span>testSecurity<span style="color: #009900;">&#40;</span>inputText<span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&amp;&amp;</span><span style="color: #009900;">&#40;</span>error<span style="color: #339933;">==</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
					<span style="color: #009900;">&#123;</span> <span style="color: #006600; font-style: italic;">// field needs to be URL format</span>
						error <span style="color: #339933;">=</span> <span style="color: #CC0000;">5</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
				<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>error<span style="color: #339933;">&gt;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span><span style="color: #006600; font-style: italic;">// there's some errors</span>
					<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>error<span style="color: #339933;">==</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> 
					<span style="color: #009900;">&#123;</span> 
						$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">next</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'span.error'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;?</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">next</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'span.ok'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;span class=&quot;error&quot;&gt;This is a required field&lt;/span&gt;'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">insertAfter</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'rel'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'error'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
					<span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>error<span style="color: #339933;">==</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span> 
					<span style="color: #009900;">&#123;</span> 
						$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">next</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'span.error'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;?</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">next</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'span.ok'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;span class=&quot;error&quot;&gt;Digits only please&lt;/span&gt;'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">insertAfter</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'rel'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'error'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
					<span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>error<span style="color: #339933;">==</span><span style="color: #CC0000;">3</span><span style="color: #009900;">&#41;</span> 
					<span style="color: #009900;">&#123;</span> 
						$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">next</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'span.error'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;?</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">next</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'span.ok'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;span class=&quot;error&quot;&gt;Invalid email&lt;/span&gt;'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">insertAfter</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'rel'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'error'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
					<span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>error<span style="color: #339933;">==</span><span style="color: #CC0000;">4</span><span style="color: #009900;">&#41;</span> 
					<span style="color: #009900;">&#123;</span> 
						$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">next</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'span.error'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;?</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">next</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'span.ok'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;span class=&quot;error&quot;&gt;Invalid URL&lt;/span&gt;'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">insertAfter</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'rel'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'error'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
					<span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>error<span style="color: #339933;">==</span><span style="color: #CC0000;">5</span><span style="color: #009900;">&#41;</span> 
					<span style="color: #009900;">&#123;</span> 
						$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">next</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'span.error'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;?</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">next</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'span.ok'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;span class=&quot;error&quot;&gt;Incorrect answer&lt;/span&gt;'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">insertAfter</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'rel'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'error'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
					<span style="color: #000066; font-weight: bold;">else</span>
					<span style="color: #009900;">&#123;</span> 
						$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">next</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'span.error'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;?</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">next</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'span.ok'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;span class=&quot;error&quot;&gt;Unknown error&lt;/span&gt;'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">insertAfter</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'rel'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'error'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
				<span style="color: #009900;">&#125;</span>
				<span style="color: #000066; font-weight: bold;">else</span>
				<span style="color: #009900;">&#123;</span>
					$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">next</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'span.error'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">next</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'span.ok'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;span class=&quot;ok&quot;&gt;Ok&lt;/span&gt;'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">insertAfter</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeAttr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'rel'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>errors<span style="color: #339933;">==</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">else</span> 
		<span style="color: #009900;">&#123;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#contactform input.button'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeAttr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'disabled'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#contactform input.button'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Correct errors and resend'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span> 
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>



<p>
First line binds the submit event to the function to be executed. The following two lines disable the submit button and change the text on it. This way users won't be able to submit again the form if their connection is slow or the server is on heavy load. Changing the text will also alert users that their action was successful and their request is being processed.
</p>
<p>
We remove all <em>error</em> span elements that may have been added by on the fly validation because the code that's about to be executed will make the final checkups all over again. The code between the 8th line and the 82nd will check all fields that have an <em>error</em> class assigned to them, check out what is required for the field to validate and display messages just as the inline validation does (on the fly validation).
</p>
<p>
If no errors are reported, the function returns true and allows the form to submit itself (the <em>return true</em> on line 86 does the trick ). If there were any errors reported, the submit button's text is set such that the user sees there were processing errors. During this stage (lines 89 to 91) the button is re-enabled and default behavior of the form is prevented. The <em>return false</em> won't allow the form to be submitted towards the server's processing script.
</p>
<p>That's all folks. We're done with client-side validation, but as mentioned above, we need to move to the mandatory part of the validation process, which is done on the server, were nobody can ruin things.
<h2>Server side validation</h2>
<p>
I'm going to cover a server side validation process written in php. PHP is very popular and other languages or frameworks such as RubyOnRails are straightforward when it comes to validating data in forms. As you've seen in the beginning of the tutorial, we have a couple of input fields and textareas we need to process. Therefor, we start our PHP by getting and storing the data filled in by the users.
</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">		<span style="color: #000088;">$name</span><span style="color: #339933;">=</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>                                    
		<span style="color: #000088;">$email</span><span style="color: #339933;">=</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'email'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$phone</span><span style="color: #339933;">=</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'phone'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$company</span><span style="color: #339933;">=</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'company'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$message</span><span style="color: #339933;">=</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'message'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$security</span><span style="color: #339933;">=</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'security'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>



<p>
We then check if there's any required field that has not been filled. If javascript is on, these validation lines of code are pretty useless, but they need to be here because they are the last ones preventing malicious data entering your webserver.
</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #339933;">==</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">||</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$email</span><span style="color: #339933;">==</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">||</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$phone</span><span style="color: #339933;">==</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">||</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$message</span><span style="color: #339933;">==</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">||</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$security</span><span style="color: #339933;">==</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">//some error message }</span></pre></td></tr></table></div>



<p>
If there were no errors at the previous check, we move forward and check if the email is valid, if the phone number contains only digits and if the security question has been answered correctly.
</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;/^[-\w.]+@([A-z0-9][-A-z0-9]+\.)+[A-z]{2,4}$/&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$email</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">//error message</span>
                <span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">is_numeric</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$phone</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">//error message</span>
                <span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$security</span><span style="color: #339933;">!=</span><span style="color: #0000ff;">&quot;three&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&amp;&amp;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$security</span><span style="color: #339933;">!=</span><span style="color: #0000ff;">&quot;3&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&amp;&amp;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$security</span><span style="color: #339933;">!=</span><span style="color: #0000ff;">&quot;THREE&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">//error message </span>
                <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>



<p>
If we got up to this point, our data is valid, there were no errors and we can process it. If you care to send an email, you can do that. If you want to add information to the database, you might do that as well. 
</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">// no errors, process data in here                                </span>
       <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>



<h2>Server side enhancements</h2>
<p>
In the beginning of this tutorial I've pointed out that our form contains bits of php coding. The reason those variable printing are present is the following: The webform can be stored inside an external php file, which is included in our contact page. The processing page also includes this file if there were error messages. The result? The data users entered in the first stage, which is unfortunately invalid, is preserved. This enhances user experience as they don't have to type everything all over again but to correct their mistakes. Awesome right?
</p>
<h2>Conclusion</h2>
<p>
We've finally reached our ending point. We've learned in the <a href="http://www.webia.info/articles/usability/forms-cant-live-with-them-cant-live-without-them/" target="_new">first part of the tutorial</a> the structures web forms can adopt, were to use them and why to use one over another. During this second part we've learned how to code a top-aligned form, style it using modern technologies such as CSS3, how to validate its data using javascript (client-side), and how to validate data server side using php.
</p>
<p>
I hope you all enjoyed the tutorial. Please share the link to your friends. You can stay updated to new content via our <a href="http://feeds2.feedburner.com/WebInternationalAwards" target="_new">RSS feed</a> or by <a href="http://feedburner.google.com/fb/a/mailverify?uri=WebInternationalAwards&#038;loc=en_US" target="_new">email</a>.
</p>
<h2>Must read</h2>
<ul>
<li>1. <a href="http://www.webia.info/articles/usability/forms-cant-live-with-them-cant-live-without-them/" target="_self">Forms. Can’t live with them. Can’t live without them. (First part of this series)</a></li>
<li>2. <a href="http://www.webia.info/articles/tutorials/make-your-own-jquery-slider-using-xml/" target="_self">Make your own jQuery slider using XML</a></li>
<li>3. <a href="http://www.webia.info/reviews/the-smashing-book-is-indeed-smashing/" target="_self">The Smashing Book is indeed… Smashing!</a></li>
<li>4. <a href="http://www.webia.info/articles/code/enhance-your-clients-list-with-jquery-goodness/" target="_self">Enhance your clients list page with jQuery goodness</a></li>
<li>5. <a href="http://www.webia.info/articles/usability/the-change-is-here-hover-events-come-to-mobile-devices/" target="_self">The change is here. Hover events come to mobile devices</a></li>
<li>6. <a href="http://www.webia.info/articles/consistency-key-element-in-extraordinary-ux/" target="_self">Consistency. Key element in extraordinary UX</a></li>
<li>7. <a href="http://www.webia.info/articles/usability/buttons-and-usability/" target="_self">Buttons and usability</a></li>
</ul>]]></content:encoded>
			<wfw:commentRss>http://www.webia.info/articles/usability/impressive-web-forms-from-coding-to-validation/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Get rid of unused elements in your designs</title>
		<link>http://www.webia.info/articles/usability/get-rid-of-unused-elements-in-your-designs/</link>
		<comments>http://www.webia.info/articles/usability/get-rid-of-unused-elements-in-your-designs/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 11:00:32 +0000</pubDate>
		<dc:creator>Bogdan Pop</dc:creator>
				<category><![CDATA[design]]></category>
		<category><![CDATA[layout]]></category>
		<category><![CDATA[usability]]></category>
		<category><![CDATA[fold]]></category>
		<category><![CDATA[header]]></category>
		<category><![CDATA[improve]]></category>
		<category><![CDATA[optimize]]></category>
		<category><![CDATA[pageviews]]></category>
		<category><![CDATA[space]]></category>
		<category><![CDATA[traffic]]></category>
		<category><![CDATA[unsued]]></category>

		<guid isPermaLink="false">http://www.webia.info/?p=1044</guid>
		<description><![CDATA[

Just in case you didn't realize, a couple of days ago I have removed the unused header here on Web International Awards. When the blog got redesigned last year in March, that header was planned to hold huge thumbnails &#8212; if huge thumbnails is correct. However, things took off and I didn't have time to [...]]]></description>
			<content:encoded><![CDATA[<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2010/02/webia_old_header.jpg" title="Webia's old header with the unused, non-functioning slider"><img src="http://www.webia.info/wp-content/uploads/2010/02/webia_old_header.jpg" alt="Webia's old header with the unused, non-functioning slider" /></a></p>
<p>
Just in case you didn't realize, a couple of days ago I have removed the unused header here on Web International Awards. When the blog got redesigned last year in March, that header was planned to hold huge thumbnails &#8212; if huge thumbnails is correct. However, things took off and I didn't have time to finish the header and really implement post thumbnails for the most popular articles that we've published.
</p>
<p>
Finally, I got some spare minutes, and I completely removed that ugly header and awful message it contained. The reason why I am giving this advice is that soon after the unused header was removed, the number of pages/visit improved with around 20%, and that can't be just a simple coincidence.
</p>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2010/02/webia_new_header.jpg" title="Webia's new header with the unused, non-functioning slider removed"><img src="http://www.webia.info/wp-content/uploads/2010/02/webia_new_header.jpg" alt="Webia's new header with the unused, non-functioning slider removed" /></a></p>
<p>
Therefor, be careful to keep the main content of your sites as high as possible. Perhaps if I fully developed the features of the header it would have resulted in better traffic towards older articles, but I think it is more important to keep new visitors as long as possible on current articles.
</p>
<p>If you enjoyed this article you can stay updated to new content via our <a href="http://feeds2.feedburner.com/WebInternationalAwards" target="_new">RSS feed</a> or by <a href="http://feedburner.google.com/fb/a/mailverify?uri=WebInternationalAwards&#038;loc=en_US" target="_new">email</a>.</p>
<h2>Further reading</h2>
<ul>
<li>1. <a href="http://www.webia.info/articles/usability/the-change-is-here-hover-events-come-to-mobile-devices/" target="_new">The change is here. Hover events come to mobile devices</a></li>
<li>2. <a href="http://www.webia.info/articles/usability/should-i-use-on-hover-behavior/" target="_new">Should I use on hover behavior?</a></li>
<li>3. <a href="http://www.webia.info/articles/javascript-articles/javascript-dos-and-donts-complete-with-17-examples-from-real-web/" target="_new">Javascript DOs and DONTs. Complete with 17 examples from real web</a></li>
<li>4. <a href="http://www.webia.info/articles/consistency-key-element-in-extraordinary-ux/" target="_new">Consistency. Key element in extraordinary UX</a></li>
</ul>]]></content:encoded>
			<wfw:commentRss>http://www.webia.info/articles/usability/get-rid-of-unused-elements-in-your-designs/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Think outside the box! &#8220;the team&#8221; perfect page!</title>
		<link>http://www.webia.info/articles/usability/think-outside-the-box-the-team-perfect-page/</link>
		<comments>http://www.webia.info/articles/usability/think-outside-the-box-the-team-perfect-page/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 14:24:15 +0000</pubDate>
		<dc:creator>Bogdan Pop</dc:creator>
				<category><![CDATA[design]]></category>
		<category><![CDATA[layout]]></category>
		<category><![CDATA[usability]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[source code]]></category>
		<category><![CDATA[the team page]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://www.webia.info/?p=136</guid>
		<description><![CDATA[

Demo preview?
Just in case you can't wait till the end of the article, here's a demo of what we're doing today in this tutorial.

Concept

Each time you get to a site to check out who works at a certain company you end up on a page that looks dull and familiar. Sometimes you have all the [...]]]></description>
			<content:encoded><![CDATA[<p class="imgpreview"><a href="http://demos.webia.info/team_page/team_page.html" title="Preview of the end result of this tutorial" target="_new"><img src="http://www.webia.info/wp-content/uploads/2009/03/team_page_main.jpg" alt="tutorial demo screenshot" /></a></p>

<h2>Demo preview?</h2>
<p>Just in case you can't wait till the end of the article, <a href="http://demos.webia.info/team_page/team_page.html" target="_new">here's a demo</a> of what we're doing today in this tutorial.</p>

<h2>Concept</h2>

<p>Each time you get to a site to check out who works at a certain company you end up on a page that looks dull and familiar. Sometimes you have all the management team or if the company is kinda small all the people employed. You have for each one a picture, a name and perhaps some contact information. Sometimes there's even a short bio.</p>

<p>All this information is usually boxed in the same way. Picture to the left, name beneath the picture, bio to the right and contact information underneath the bio. If there's no bio, you simply have contact information to the right.</p>

<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2010/01/teampage_aboutus_example.jpg" title="About page of 37 signals"><img src="http://www.webia.info/wp-content/uploads/2010/01/teampage_aboutus_example.jpg" alt="Example of an about us page" /></a></p>

<p>I am sick and tired of this "inside the box" thinking. In fact, I recently stumbled on the site of a company that could have been my client today - I paid them a visit about three years ago. Found the office closed with no information provided. There was no secretary. I had nobody to pitch to, so no new client. They now have a nice page to round up the management of the company. Unfortunately, the implementation lacks my minimum moral standard.</p>

<p>If I recall correctly those functions that start with <em>function MM_swapImgRestore()</em> are generated via Dreamweaver, which in my opinion is for, uhm, well, kids. The rollovers are created using Flash. I borrowed the concept and did a XHTML / CSS / jQuery implementation. Moreover, I am sharing the full source code and the development process as a tutorial, and you can use it for free as long as you credit the author.</p>

<h3>Original design</h3>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2010/01/teampage_original_example.jpg" title="Screenshot of Edil Concept's about us page"><img src="http://www.webia.info/wp-content/uploads/2010/01/teampage_original_example.jpg" alt="Screenshot of Edil Concept's about us page" /></a></p>

<p>The site where I got this idea from is the site of a local constructions company called <a href="http://www.edilconcept.ro/echipa.html" target="_new">Edil Concept</a>. Sorry it is available only in Romanian. Check out how their team page looks like. It has those nice image rollovers and the right box next to them for displaying information. It does have a small downside though. If you want to email that dude in the middle of the team - which is actually the company's manager - you have to write down his email on paper, because content changes when you hover any of the images, and his stuck in the middle.</p>

<h3>Improved design</h3>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2010/01/teampage_demo_two.jpg" title="Second preview of the end result of this tutorial"><img src="http://www.webia.info/wp-content/uploads/2010/01/teampage_demo_two.jpg" alt="tutorial demo screenshot" /></a></p>
<p>Here's what we want to achieve. First of all, the above described layout should be achieved using only XHTML and CSS. No tables as they are so old and ugly. We also want to change from hovering behavior to clicking behavior. Doing so will ensure that you can actually use the information displayed for the middle guy. In order to achieve this we will use jQuery. <del datetime="2009-03-26T08:45:17+00:00">The hovering effect will be kept, so that people look around as you go through them.</del> As it turns out, doing this on hover, really, really doesn't work. Do not try this at home! No really, don't!</p>

<p>Don't believe me, just <a href="http://demos.webia.info/team_page/team_page_hover_crazyness.html" target="_self">see here</a> what happens if hovering behavior is preserved.</p>

<h3>The layout</h3>
<p>We will have three major boxes in this layout. We will have a <em>wrapper</em>, a <em>photos</em> and a <em>text</em> box. The wrapper will hold the content in place, in the middle of the page. The photos will hold the 9 pictures we will have - our demo company has 9 employees. I don't think I need to say what the text box will contain. Check out the <a href=http://demos.webia.info/team_page/layout.html" target="_self">layout page</a>.</p>

<h3>The XHTML</h3>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;h1&gt;Team page demo&lt;/h1&gt; &lt;!-- title so demo looks nice --&gt;
&nbsp;
	&lt;div id=&quot;wrapper&quot;&gt; &lt;!-- hold content in place --&gt;
&nbsp;
		&lt;div id=&quot;photos&quot;&gt; &lt;!-- hold all pictures together --&gt;
			&lt;a class=&quot;member&quot; id=&quot;img1&quot;&gt;&lt;img id=&quot;image1&quot; src=&quot;images/default.jpg&quot; width=&quot;140&quot; height=&quot;140&quot; alt=&quot;Default&quot; /&gt;&lt;/a&gt;
			&lt;a class=&quot;member&quot; id=&quot;img2&quot;&gt;&lt;img id=&quot;image2&quot; src=&quot;images/default.jpg&quot; width=&quot;140&quot; height=&quot;140&quot; alt=&quot;Default&quot; /&gt;&lt;/a&gt;
			&lt;a class=&quot;member&quot; id=&quot;img3&quot;&gt;&lt;img id=&quot;image3&quot; src=&quot;images/default.jpg&quot; width=&quot;140&quot; height=&quot;140&quot; alt=&quot;Default&quot; /&gt;&lt;/a&gt;
			&lt;a class=&quot;member&quot; id=&quot;img4&quot;&gt;&lt;img id=&quot;image4&quot; src=&quot;images/default.jpg&quot; width=&quot;140&quot; height=&quot;140&quot; alt=&quot;Default&quot; /&gt;&lt;/a&gt;
			&lt;a class=&quot;member&quot; id=&quot;img5&quot;&gt;&lt;img id=&quot;image5&quot; src=&quot;images/default.jpg&quot; width=&quot;140&quot; height=&quot;140&quot; alt=&quot;Default&quot; /&gt;&lt;/a&gt;
			&lt;a class=&quot;member&quot; id=&quot;img6&quot;&gt;&lt;img id=&quot;image6&quot; src=&quot;images/default.jpg&quot; width=&quot;140&quot; height=&quot;140&quot; alt=&quot;Default&quot; /&gt;&lt;/a&gt;
			&lt;a class=&quot;member&quot; id=&quot;img7&quot;&gt;&lt;img id=&quot;image7&quot; src=&quot;images/default.jpg&quot; width=&quot;140&quot; height=&quot;140&quot; alt=&quot;Default&quot; /&gt;&lt;/a&gt;
			&lt;a class=&quot;member&quot; id=&quot;img8&quot;&gt;&lt;img id=&quot;image8&quot; src=&quot;images/default.jpg&quot; width=&quot;140&quot; height=&quot;140&quot; alt=&quot;Default&quot; /&gt;&lt;/a&gt;
			&lt;a class=&quot;member&quot; id=&quot;img9&quot;&gt;&lt;img id=&quot;image9&quot; src=&quot;images/default.jpg&quot; width=&quot;140&quot; height=&quot;140&quot; alt=&quot;Default&quot; /&gt;&lt;/a&gt;
		&lt;/div&gt;
&nbsp;
		&lt;div id=&quot;moretext&quot;&gt; &lt;!-- hold content that will show up once photos on the left are clicked --&gt;
			&lt;span&gt;Click the images on the left to view detailed information about us.&lt;/span&gt;
			&lt;h2&gt;&lt;/h2&gt;
			&lt;h3&gt;&lt;/h3&gt;
			&lt;h4&gt;&lt;/h4&gt;
			&lt;h5&gt;&lt;/h5&gt;
			&lt;h6&gt;&lt;/h6&gt;
		&lt;/div&gt;
&nbsp;
	&lt;/div&gt;</pre></td></tr></table></div>



<h3>XHTML explained</h3>
<p>I won't explain all the small details behind the XHTML code above. However, I feel I need to explain why images are wrapped in anchor tags. I did this so that I could easily style the hover event of images with a nice border, and to cleanly add spacing between images. I also added an ID attribute to each anchor tag because I am going to use those combined with jQuery. Each image has an ID attribute too because we will need to change the SRC attribute of each image when one of them is pressed. We do that with jQuery and use the IDs to identify the elements, that's why make sure your IDs will have unique names if you use this in a production environment.</p>

<p>The <em>#photos</em> div will be floated to the left, while the <em>#moretext</em> div will be floated to the right. The heading tags will be populated with content once an image is clicked, while the span tag will be removed when that happens. We don't need IDs for these heading tags as they're all different and share the same parent. We can identify them by their parent and type.</p>

<h3>CSS code</h3>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* RESET - we don't want anything to interfere with our styles */</span>
<span style="color: #00AA00;">*</span>										<span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">outline</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">inherit</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #993333;">inherit</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #808080; font-style: italic;">/* END RESET */</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* GLOBAL LAYOUT CONFIG */</span>
body									<span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #933;">50px</span> <span style="color: #933;">0px</span> <span style="color: #933;">0px</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
										  <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> <span style="color: #ff0000;">&quot;Lucida Grande&quot;</span><span style="color: #00AA00;">,</span> Verdana<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span> <span style="color: #808080; font-style: italic;">/* don't let content start right from the top */</span>
h1										<span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span><span style="color: #993333;">center</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">800px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #933;">0px</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">30px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">1.3em</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#wrapper</span>								<span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #933;">0px</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">800px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">450px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span> <span style="color: #808080; font-style: italic;">/* set width and height, positioning */</span>
<span style="color: #cc00cc;">#photos</span>									<span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">450px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">450px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span> <span style="color: #808080; font-style: italic;">/* set width, height and floating */</span>
<span style="color: #cc00cc;">#moretext</span>								<span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">430px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">330px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#EEE</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span> <span style="color: #808080; font-style: italic;">/* set width, height, floating and background color of text area */</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* END GLOBAL LAYOUT CONFIG */</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* PHOTOS STYLING */</span>
<span style="color: #cc00cc;">#photos</span> <span style="color: #6666ff;">.member</span>							<span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">0px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #933;">5px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#CCC</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">140px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">140px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#photos</span> <span style="color: #6666ff;">.member</span><span style="color: #3333ff;">:hover					</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #933;">5px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#333</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #808080; font-style: italic;">/* the most important attributes are the floating, and the border used to space the elements */</span>
<span style="color: #808080; font-style: italic;">/* END PHOTOS STYLING */</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* simple text styling */</span>
<span style="color: #cc00cc;">#moretext</span> span							<span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">0.8em</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#moretext</span> 								<span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#333</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#moretext</span> h2							<span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">1.2em</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#moretext</span> h3							<span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">0.7em</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#moretext</span> h4<span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#moretext</span> h5				<span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">0.8em</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#moretext</span> h6							<span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">0.7em</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">25px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>




<h3>CSS explained</h3>
<p>We set document limits, then set the wrapper's dimensions. Somewhat important is the width and height of the photos box, which is 450 pixels because we have 3 images on a row, and 3 different rows. This means each image should be 150 by 150 pixels. That is not true however due to the fact that we added the anchor tag which has a 5 pixels border. Therefor images should be 140 pixels in height and width. You can check how the layout looks with CSS applied to it <a href="http://demos.webia.info/team_page/layout_css.html" target="_self">over here</a>.</p>
<p>As you have seen so far, neither the XHTML nor the CSS are complicated, and hopefully the jQuery will not look complicated at all. With this said, let's jump into the interesting part of the article.</p>

<h3>Scripting with jQuery</h3>
<p>Clicking on images doesn't trigger anything yet. That's why we need to spice things up with a little jQuery. We will be using jQuery's <em>.click()</em>, <em>.remove()</em>, <em>.attr()</em> and <em>.text()</em> functionalities. It is obvious what <em>.click()</em> will be used for. The <em>.remove()</em> function will be used to remove the welcome text - which is contained in the <em>span</em> tag - out from the text box after the first click on an image.</p>

<p><em>.text()</em> will be used to change the contents of the heading tags once images are clicked, while the <em>.attr()</em> will be used to change the SRC attribute of images as we click through them. Take a look at the jQuery code to see what you're up against.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #006600; font-style: italic;">// the following code will remove the info on top of the right box</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#photos a&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#moretext span&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #006600; font-style: italic;">// the following 9 functions will edit information about each employee</span>
&nbsp;
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#img1&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
		<span style="color: #006600; font-style: italic;">// change the text in the right box</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#moretext h2&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Bogdan Pop&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#moretext h3&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;General Manager&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#moretext h4&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;+40 (954) 037 910&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#moretext h5&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;mailhere@domain.com&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#moretext h6&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Bogdan Pop is a young Romanian entrepreneur who runs WebRaptor. He loves web programming and design and has a passion for standards and SEO. He relaxes by taking photos every once in a while and by mixing french electronic music.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #006600; font-style: italic;">// change the pictures on the left</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#image1&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;src&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;images/hey.jpg&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#image2&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;src&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;images/l.jpg&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#image3&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;src&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;images/l.jpg&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#image4&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;src&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;images/t.jpg&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#image5&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;src&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;images/lt.jpg&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#image6&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;src&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;images/lt.jpg&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#image7&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;src&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;images/t.jpg&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#image8&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;src&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;images/lt.jpg&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#image9&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;src&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;images/lt.jpg&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #006600; font-style: italic;">// 8 more .click functions will be here</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>




<h3>jQuery explained</h3>
<p>The first thing that happens when we click an image is the removal of the <em>span</em> tag together with its content. We do that with the <em>.remove()</em> function that we call upon the tag we're looking for. That is identified using <em>#moretext span</em> identifier, and we call it once an image is clicked. We do that with the <em>.click()</em> trigger applied to the anchor tags that wrap the images: <em>#photos a</em>. Here's the code that does that.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#photos a&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #006600; font-style: italic;">// function called when image anchor is clicked</span>
	<span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#moretext span&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// remove the span tag inside the #moretext div</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>




<p>Next, whenever a specific image is clicked, like the one above identified as <em>img1</em> using its ID, we need to change the text of the heading tags in the text area of the demo (#moretext div) and also update the sources of all images. As you've seen in the <a href="http://www.edilconcept.ro/echipa.html" target="_blank">original site</a> or in the <a href="http://demos.webia.info/team_page/team_page.html" target="_self">live demo</a>, we change the image of each employee to appear as if they were all looking to whom you've just clicked upon. Here's the code we use to change a heading tag as I've just described.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#moretext h2&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Bogdan Pop&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>




<p>In the above code I've identified the level two heading and changed its contents using jQuery's <em>.text()</em> function. By using the <em>.attr()</em> function with two arguments, we change the SRC attribute of an image. We identify images using their IDs that we uniquely named them with in the XHTML such as <em>image6</em>. Here's the code used to change the source of an image.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#image6&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;src&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;images/lt.jpg&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>




<h3>The result</h3>
<p>This is pretty much everything you need to know to achieve what I've done in <a href="http://demos.webia.info/team_page/team_page.html" target="_self">this demo</a>. Because the entire jQuery code used is almost 200 lines of code, I haven't posted it entirely over here, but it is basically the same scenario as applied above to <em>img1</em>, and it is fully available in the source code of this tutorial. <a href="http://demos.webia.info/team_page/js/sprinkle.js">Sprinkle.js</a> file is the one used to achieve the demo in this tutorial, while <a href="http://demos.webia.info/team_page/js/sprinkle_hover_crazyness.js">sprinkle_hover_crazyness.js</a> is used to achieve a page that works similarly to the original site, which I don't recommend.</p>

<h3>Download</h3>
<p>You can download and use the code above <a href="http://demos.webia.info/team_page/source.zip">from here</a>. If you enjoyed this article you can stay updated to new content via our <a href="http://feeds2.feedburner.com/WebInternationalAwards" target="_new">RSS feed</a> or by <a href="http://feedburner.google.com/fb/a/mailverify?uri=WebInternationalAwards&#038;loc=en_US" target="_new">email</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.webia.info/articles/usability/think-outside-the-box-the-team-perfect-page/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Forms. Can&#8217;t live with them. Can&#8217;t live without them.</title>
		<link>http://www.webia.info/articles/usability/forms-cant-live-with-them-cant-live-without-them/</link>
		<comments>http://www.webia.info/articles/usability/forms-cant-live-with-them-cant-live-without-them/#comments</comments>
		<pubDate>Sat, 07 Nov 2009 15:25:38 +0000</pubDate>
		<dc:creator>Bogdan Pop</dc:creator>
				<category><![CDATA[design]]></category>
		<category><![CDATA[usability]]></category>
		<category><![CDATA[experience]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[inline]]></category>
		<category><![CDATA[left aligned]]></category>
		<category><![CDATA[right aligned]]></category>
		<category><![CDATA[top aligned]]></category>
		<category><![CDATA[webform]]></category>

		<guid isPermaLink="false">http://www.webia.info/?p=832</guid>
		<description><![CDATA[
What language does your local store clerk speak? Your own language you say. What language do the web forms you build speak? Do they speak the same language as your site's visitors? Your clerk greets you with a smile. Do your forms smile to your clients?

It is fascinating how bad web forms look and work [...]]]></description>
			<content:encoded><![CDATA[<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2009/11/form_labels_top.jpg"><img src="http://www.webia.info/wp-content/uploads/2009/11/form_labels_top.jpg" alt="Edward Pistachio contact form screenshot" /></a></p>
<p>What language does your local store clerk speak? Your own language you say. What language do the web forms you build speak? Do they speak the same language as your site's visitors? Your clerk greets you with a smile. Do your forms smile to your clients?</p>

<p>It is fascinating how bad web forms look and work on most sites that are out there. The problem is that they are usually on the last place on the to-do or check-up list, which is totally wrong. Let me explain why this approach is wrong. A web form is practically the clerk of a site, whether it is a simple site or a huge e-commerce website. As you have the clerk in the supermarket to handle check out, you have web forms on the web to handle all sorts of things, from contacts, to payment processing, to newsletters signups and so on. All these features inside your site are powerful tools for your business.</p>

<h2>Not caring for your web forms is not caring for your clients! Not caring for your clients is not caring for your business!</h2>

<p>Put yourself into your customer's shoes. From now on, you will have to build web forms accordingly, because better web forms will attract more prospects, which will end up in more sales, and better business. This sounds great given the financial crysis that has got many businesses bankrupt.</p>

<p>This article will cover all you will need in order to create useful, beautiful forms. The first part will handle the theoretical part, describing different scenarios and structures web forms could have. The second part will cover the XHTML / CSS implementation of all forms, and the last part will cover the validation and processing of the forms.</p>

<span id="more-832"></span>

<h2>PART I</h2>
<p>If you got here, you know that web forms suck. I don't like them, you don't like them, our customers don't like them. Nobody likes web forms. That usually happens because we don't design them the right way. Most of us make forms to get information about everything, then do something with it when our goal should be getting everybody through the form as quickly and easily as possible. We want a lot of information from our customers, but they are facing a stranger. They are facing a stranger who wants their information. Why should they give it to us.</p>

<p>When someone comes to a form, they want to get passed it and do whatever they were promised to be able to do before completing the form. That's why the number one priority when building a form should be keeping it simple. And now comes the hard part. Forms can be designed in many ways, but which one is the simplest? Well, to tell you the truth, I haven't found the answer yet. But hey, at least I tested some options.</p>

<p>First thing's first. Make sure you strip out content that you don't really need! Don't think about sending an email to your client? Don't ask them their email. Don't want to fax them? Don't ask for fax numbers. Once you have the few questions you really need to ask, you can outline them in different ways inside an online form.</p>

<h2>The 4-ways of forms</h2>
<p>If you look around all forms on the internet, they all share something. A bunch of them have right-aligned labels, some other have left-aligned labels, some have top-aligned labels, and lately, there's some forms out there that have labels inside the input fields. But which one is best? That depends on the purpose of each form. So lets check out each and every one of them.</p>

<h2>Inline labels</h2>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2009/11/inline_label.jpg" title="Inline labels, best suited for small forms like a login form"><img src="http://www.webia.info/wp-content/uploads/2009/11/inline_label.jpg" alt="inline labels screenshot" /></a></p>
<p>Inline labels are great, because they can reduce the amount of space your form spans across. However, these forms are usually handled with a relatively big amount of coding. We have two scenarios for these kind of forms.</p>

<h2>Static text within input fields</h2>
<p>What happens here when a user clicks inside a label is, well, nothing. Given the "username" field, clicking it means that the user has to first delete the text, and then input his actual username. This is ok for small forms, but doing this on a huge form will definitely scare you off.</p>

<h2>Dynamic text within input fields</h2>
<p>These input fields work like magic, because when the user clicks the input field, the "username" label text just disappears, and they can input their username quickly. Great.</p>

<p>The downside of both solutions is that we practically cannot use this kind of design on long forms. Short forms like searching or logging could really use this design technique, but long forms no. That is simply because when you're finished and want to check the form before submitting, there's a big chance you don't remember what the questions were.</p>

<h2>Pros for inline labels</h2>
<ol>
<li>Reduce the space required by the form</li>
</ol>

<h2>Cons for inline labels</h2>
<ol>
<li>Not knowing what you answered for</li>
<li>Label text doesn't go away, and distracts the user while typing</li>
<li>Label text goes away on click, and doesn't come back if the user didn't type anything</li>
</ol>

<h2>Left-aligned labels</h2>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2009/11/left_aligned_labes.jpg" title="Left aligned labels allow easier scanning for required information"><img src="http://www.webia.info/wp-content/uploads/2009/11/left_aligned_labes.jpg" alt="left aligned labels screenshot" /></a></p>
<p>These forms are best if you request god knows what information, and the users need to check out personal documents in order to know how to answer your questions. Left aligned labels help because all questions are one below each other, and input fields do not interfere. This way, users can scan to see what they are asked for, and get prepared before setting on the quest of completing your form.</p>

<p>The next thing these forms are good at is reducing vertical space. However, if you have long questions, this may be an issue as the width of the form will extend, and sometimes the overall layout of a form could be completely messed up. Nowadays however, browser screen resolution is pretty big, so this issue probably isn't a big problem. But make sure that the percent of mobile visitors is low if you're willing to adopt such a form.</p>

<h2>Pros for left-aligned labels</h2>
<ol>
<li>Reduce vertical span of the form</li>
<li>Easy scan the questions before doing anything else</li>
</ol>

<h2>Cons for left-aligned labels</h2>
<ol>
<li>Harder to connect the labels with their adjacent input field</li>
<li>Increased horizontal space the forms spans on</li>
</ol>

<h2>Right-aligned labels</h2>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2009/11/right_aligned_labels.jpg" title="Right aligned labels example"><img src="http://www.webia.info/wp-content/uploads/2009/11/right_aligned_labels.jpg" alt="Right aligned labels screenshot" /></a></p>
<p>Right-aligned labels have the same disadvantage as left-forms do, so if the horizontal space is not generous, they are not an option. On the other side, if the left-aligned forms are bad in terms of connecting each label with its corresponding input field, right aligned labels don't suffer from that, as they are inches away from the input fields. However, these forms cannot be easily scanned. Basically, these one are the exact opposite of left-aligned labels. Well, not exactly, but you'll see why further along.</p>

<h2>Pros for right-aligned labels</h2>
<ol>
<li>Reduce vertical span of the form</li>
<li>Easy to connect the labels with their adjacent input field</li>
</ol>

<h2>Cons for right-aligned labels</h2>
<ol>
<li>Hard to scan the questions before doing anything else</li>
<li>Increased horizontal space the forms spans on</li>
</ol>

<h2>Left/Right or Right/Left</h2>
<p>Now, in the western world, we read text from left to right. Therefore, we can scan left-aligned labels very fast. However, have in mind that Arabic and Hebrew are read from right to left, so right-aligned labels are scanned easier in such a case. Make sure you make the right choice based on what language your visitors speak.</p>

<h2>Top-aligned labels</h2>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2009/11/top_aligned_labels.jpg" title="Example of top aligned labels inside a group"><img src="http://www.webia.info/wp-content/uploads/2009/11/top_aligned_labels.jpg" alt="top algined labels screenshot" /></a></p>
<p>Top aligned labels are great. They are somewhat easy to scan through. They can have long questions, without worries of destroying the overall layout. Some questions, like city and zip code or phone and ext. could be grouped together on the same line. Having the labels on top of input fields means faster and easier processing. So, you should probably use these kind of forms whenever you want to get the thing done fast, and vertical space is not an issue, because yes, they do take up quite some vertical space.</p>

<h2>Pros for top-aligned labels</h2>
<ol>
<li>Can have long questions.</li>
<li>Can group together similar information</li>
<li>Fast processing</li>

<h2<Cons for top-aligned labels</h2>
<ol>
<li>They need a lot of vertical space</li>
<li>They can't be long just for the above reason</li>
</ol>

<h2>Completion times of all 4 types</h2>
<p>Left aligned labels could have quite some span between them and their adjacent input field, so users are forced to take more time when interacting with the form. The right aligned labels reduce the eye fixations imposed by the left aligned labels to almost a half, and reduce the cognitive load users need to complete the form. Top aligned labels allow users to capture the label and input field at once, with only one eye movement. Inline fields are a better than top aligned labels, but remember when you must not use them. For further info on completion times, you can check out Matteo Penzo's article <a href="http://www.uxmatters.com/mt/archives/2006/07/label-placement-in-forms.php" target="_new">Label Placement in Forms</a>.</p>

<h2>Must read</h2>
<p>I totally recommend you read Luke Wrobleski's book <a href="http://www.lukew.com/resources/web_form_design.asp" target="_new">Web Form Design: Filling in the Blanks</a>. The amount of valuable information it contains is priceless.</p>

<h2>Conclusion</h2>
<p>We are now done with the theoretical part of web forms design. Well, we know the basics of web forms design. In the next part of this tutorial we will discuss how to implement using XHTML and CSS all the 4 types of forms described above. Stay toned.</p>

<h2>PART II and PART III</h2>
<p>Part two and part three of this series will contain the XHTML &#038; CSS for the forms and form validation. If you liked this article you can stay updated and get new content via our <a href="http://feeds2.feedburner.com/WebInternationalAwards" target="_new">RSS feed</a>.</p>

<h2>Comments</h2>
<p>Now if you reached this far, I really recommend reading forward the comments section two, because there's plenty of useful information shared there as well.</p>]]></content:encoded>
			<wfw:commentRss>http://www.webia.info/articles/usability/forms-cant-live-with-them-cant-live-without-them/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Graceful flash degradation, reloaded!</title>
		<link>http://www.webia.info/articles/graceful-flash-degradation-reloaded/</link>
		<comments>http://www.webia.info/articles/graceful-flash-degradation-reloaded/#comments</comments>
		<pubDate>Mon, 21 Sep 2009 11:07:25 +0000</pubDate>
		<dc:creator>Bogdan Pop</dc:creator>
				<category><![CDATA[articles]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[techniques]]></category>
		<category><![CDATA[usability]]></category>
		<category><![CDATA[degradation]]></category>
		<category><![CDATA[html]]></category>

		<guid isPermaLink="false">http://www.webia.info/?p=582</guid>
		<description><![CDATA[
A couple of weeks ago I talked about graceful flash degradation: what it means, issues that arise while developing in flash, and how to fix them properly. This is the second article on the topic. Before we continue, make sure you're familiar with the first article on flash degradation, because this article contains examples to [...]]]></description>
			<content:encoded><![CDATA[<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2009/09/nyt_flash.jpg" title="New York Times Photojournalism section: flash version"><img src="http://www.webia.info/wp-content/uploads/2009/09/nyt_flash.jpg" alt="NYT photojournalism section, flash version" /></a></p>
<p>A couple of weeks ago I talked about graceful flash degradation: what it means, issues that arise while developing in flash, and how to fix them properly. This is the second article on the topic. Before we continue, make sure you're familiar with the first article on <a href="http://www.webia.info/articles/usability/graceful-flash-degradation/">flash degradation</a>, because this article contains examples to emphasize what the previous article described.</p>
<h2>Good flash degradation from New York Times</h2>
<p>We previously stumbled upon UEFA's site and a wine company's website. Today we are looking upon a newspaper's website. The name is self explanatory, New York Times being the largest metropolitan newspaper published in the United States. Having that weight attached to their necks, they knew their online presence must be perfect. And it is. </p>
<p>New York Times has an online photojournalism section which is built in flash. It is consisted of a series of posts, each around an image. Each post has apart from the image, a brief paragraph describing the picture, where it was taken and so on. A nice feature is the small sneak peak to the next and previous articles, which are visible in the left and right sidebars of the article you are currently viewing. However, I don't think this was a feature they specifically developed, as the full screen mode lacks it.</p>
<p>What really matters here is that they also have a non flash version of the site which kicks in if you do not have the necessary plugins. They also let you know that if you want to fully enjoy the features of the site, you should install flash player. Flawless solution. Great job for New York Times, but perhaps more congrats should go to the site developers, whoever they are.</p>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2009/09/nyt_non_flash.jpg" title="New York Times Photojournalism section: non-flash version"><img src="http://www.webia.info/wp-content/uploads/2009/09/nyt_non_flash.jpg" alt="NYT photojournalism section, non-flash version" /></a></p>
<p>If you have any other examples or pointers please leave them in the comments section bellow. If you liked this article you can subscribe to the full content <a href="http://feeds2.feedburner.com/WebInternationalAwards" target="_new">rss feed</a> and stay updated as we post new information.</p>]]></content:encoded>
			<wfw:commentRss>http://www.webia.info/articles/graceful-flash-degradation-reloaded/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Site redesign &amp; how to lose 50% of your business</title>
		<link>http://www.webia.info/articles/site-redesign-how-to-lose-50-of-your-business/</link>
		<comments>http://www.webia.info/articles/site-redesign-how-to-lose-50-of-your-business/#comments</comments>
		<pubDate>Mon, 14 Sep 2009 12:52:47 +0000</pubDate>
		<dc:creator>Bogdan Pop</dc:creator>
				<category><![CDATA[articles]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[layout]]></category>
		<category><![CDATA[usability]]></category>
		<category><![CDATA[bad]]></category>
		<category><![CDATA[business]]></category>
		<category><![CDATA[low]]></category>
		<category><![CDATA[miss]]></category>
		<category><![CDATA[poor]]></category>
		<category><![CDATA[redesign]]></category>
		<category><![CDATA[structure]]></category>

		<guid isPermaLink="false">http://www.webia.info/?p=512</guid>
		<description><![CDATA[
A couple of months ago I wrote an article about service marketplaces, and one such marketplace I gave as example was guru.com. This article is again about the same site, which was recently poorly redesigned.
How to kick out 50% of your potential clients
There are two categories of companies, or for that matter could be people [...]]]></description>
			<content:encoded><![CDATA[<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2009/09/guru_site_redesign_graph.jpg"><img src="http://www.webia.info/wp-content/uploads/2009/09/guru_site_redesign_graph.jpg" alt="graph showing client loss after site redesign" /></a></p>
<p>A couple of months ago I wrote an article about <a href="http://www.webia.info/articles/do-service-marketplaces-still-work/" target="_new">service marketplaces</a>, and one such marketplace I gave as example was <a href="http://www.guru.com" target="_new">guru.com</a>. This article is again about the same site, which was recently poorly redesigned.</p>
<h2>How to kick out 50% of your potential clients</h2>
<p>There are two categories of companies, or for that matter could be people too, that need a website. First are the ones that do not currently have a website, and then are the ones that have a website but want their website improved. Improving is the sole purpose of a website redesign. However, Guru missed that completely in their redesign process. They did many changes, some are actually good, but you need to sign up and log in into your account to see the improvements.</p>
<p>The big issue is that their new homepage misses half of their potential clients. A service marketplace is a portal where companies that have projects sign up and post them, while others (service provides) check out the posted projects, bid on them, and then develop them. A service marketplace requires employers with projects and employees (freelancers or companies) with skills and resources to develop solutions.</p>
<p>Guru's homepage contains a lot of information for employers. It has a big chunky menu with links to "hiring, posting a project, finding freelancers". It provides means to manage your projects, pay freelancers, check your messages. But did I say you are logged in? NO. You're not logged in. They didn't adapt their site for first time visitors. Then, after a big header with guru's greatest features (a slideshow about safe payments, their million freelancers etc) you get three big tabs. Guess what? They are practically the same menu, only now in big chunky tabs. Find freelancers, post projects, discover Guru.</p>
<p>I must say that posting a project is really nice. Without having an account, you can add all your project details, then sign up et voilà, your project is posted. That's ok, but I have just finished reviewing the homepage. So, did you catch the glitch? <strong>I have been talking here only about Employers! No Employees!</strong></p>
<h2>No freelancer information on homepage</h2>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2009/09/guru_homepage.jpg"><img src="http://www.webia.info/wp-content/uploads/2009/09/guru_homepage.jpg" alt="guru.com homepage screenshot" /></a></p>
<p>Guru misses half of their clients because they didn't put any information for freelancers on their homepage. First time freelancers probably get lost in the site and don't ever get the chance to register, bid, work and make money. Awful strategy from Guru.</p>
<h2>But they do care about 50% of their business</h2>
<p>There is information for freelancers on their newly designed homepage. I am going to give you 10 seconds to discover it in the above picture. Should you not find any information for freelancers, check out the next image.</p>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2009/09/guru_homepage_emphasize.jpg"><img src="http://www.webia.info/wp-content/uploads/2009/09/guru_homepage_emphasize.jpg" alt="guru.com homepage screenshot, emphasizing the tiny link for freelancers in the upper right corner" /></a></p>
<p>All you have to do now is to always remember this issue and never do it in your own sites and wonder why things don't work smoothly. If you have any other examples or pointers please leave them in the comments section bellow. If you liked this article you can subscribe to the full content <a href="http://feeds2.feedburner.com/WebInternationalAwards" target="_new">rss feed</a> and stay updated as we post new information.</p>]]></content:encoded>
			<wfw:commentRss>http://www.webia.info/articles/site-redesign-how-to-lose-50-of-your-business/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating motion blur without special software</title>
		<link>http://www.webia.info/articles/creating-motion-blur-without-special-software/</link>
		<comments>http://www.webia.info/articles/creating-motion-blur-without-special-software/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 15:21:23 +0000</pubDate>
		<dc:creator>Bogdan Pop</dc:creator>
				<category><![CDATA[articles]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[techniques]]></category>
		<category><![CDATA[basic software]]></category>
		<category><![CDATA[blur]]></category>
		<category><![CDATA[easy]]></category>
		<category><![CDATA[effect]]></category>
		<category><![CDATA[graphic]]></category>
		<category><![CDATA[motion]]></category>
		<category><![CDATA[motion blur]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.webia.info/?p=544</guid>
		<description><![CDATA[Should you be on holiday, and run out of Photoshop, Fireworks, Illustrator or your favorite image editing software, you need not panic if you need to apply a motion blur effect to an image. You could use your camera if it is convenient (IE: you need to apply motion blur to something located next to [...]]]></description>
			<content:encoded><![CDATA[<p>Should you be on holiday, and run out of Photoshop, Fireworks, Illustrator or your favorite image editing software, you need not panic if you need to apply a motion blur effect to an image. You could use your camera if it is convenient (IE: you need to apply motion blur to something located next to you). For the purposes of this tutorial I have chosen a random landscape image. The original size of the image was 2500 by 1667 pixels, but I need it at 540 pixels by 360 pixels.</p>
<h2>Original file</h2>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2009/09/blur_original_resized.jpg" title="Original file preview"><img src="http://www.webia.info/wp-content/uploads/2009/09/blur_original.jpg" alt="original file" /></a></p>
<h2>Final outcome</h2>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2009/09/blur_final_large.jpg" title="Final result preview"><img src="http://www.webia.info/wp-content/uploads/2009/09/blur_final.jpg" alt="final result" /></a></p>
<p>To apply motion blur to a graphic element without any dedicated software, here's a few simple steps that will have decent results.</p>
<h2>1: Duplicate your graphic element</h2>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2009/09/blur_duplicate.jpg" title="Step 1: Duplicate your graphic file to graphics A and B"><img src="http://www.webia.info/wp-content/uploads/2009/09/blur_duplicate.jpg" alt="blur duplicate graphic element" /></a></p>
<p>We will duplicate our graphic element because I want to apply the blur effect to only a portion of the landscape. To be exact, I want a horizontal line that blurs the center of the image.</p>
<h2>2: Resize copy A of the element to desired size</h2>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2009/09/blur_resize_one.jpg" title="Step 2: Resize to desired size copy A"><img src="http://www.webia.info/wp-content/uploads/2009/09/blur_resize_one.jpg" alt="blur resize one graphic" /></a></p>
<p>Copy A will have to be located underneath copy B because it will be the part that will not be blurred.</p>
<h2>3: Resize the height of copy B to same height of A</h2>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2009/09/blur_resize_two.jpg" title="Step 3: Resize the height of graphic B to match A's height"><img src="http://www.webia.info/wp-content/uploads/2009/09/blur_resize_two.jpg" alt="blur resize graphic 2 height" /></a></p>
<h2>4: Resize the width of copy B to something smaller than A's width</h2>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2009/09/blur_resize_three.jpg" title="Step 4: Resize the width of copy B to something smaller than A's width"><img src="http://www.webia.info/wp-content/uploads/2009/09/blur_resize_three.jpg" alt="blur resize graphic 2 width" /></a></p>
<p>By resizing the image to a smaller width, information will be lost. Why? The original file was 2500 pixels in width. I am resizing the image to something as low as 150 pixels. More than 10 pixels will be combined to form a new one, and preserve part of the original aspect of the image.</p>
<h2>5: Resize the width of copy B to the width of A</h2>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2009/09/blur_resize_four.jpg" title="Step 5: Resize the width of copy B to the width of A"><img src="http://www.webia.info/wp-content/uploads/2009/09/blur_resize_four.jpg" alt="blur resize graphic 2 width again" /></a></p>
<p>During this resizing process, the exact opposite of step four will happen. Out of one sole pixel, many more have to be created, resulting in quality loss of the image, and the blurry effect.</p>
<h2>6: Trim excess material, while blurred image on top</h2>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2009/09/blur_final_large.jpg" title="Step 6: Trim excess material, while blurred image on top to obtain final result"><img src="http://www.webia.info/wp-content/uploads/2009/09/blur_final.jpg" alt="blur finish" /></a></p>
<p>In the final step, we trim off the header and footer of the blurred copy of the image, leaving the desired horizontal bar, on top of the original image. If you liked this article you can subscribe to the full content <a href="http://feeds2.feedburner.com/WebInternationalAwards" target="_new">rss feed</a> and stay updated as we post new information.</p>]]></content:encoded>
			<wfw:commentRss>http://www.webia.info/articles/creating-motion-blur-without-special-software/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Consistency. Key element in extraordinary UX</title>
		<link>http://www.webia.info/articles/consistency-key-element-in-extraordinary-ux/</link>
		<comments>http://www.webia.info/articles/consistency-key-element-in-extraordinary-ux/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 07:25:05 +0000</pubDate>
		<dc:creator>Bogdan Pop</dc:creator>
				<category><![CDATA[articles]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[branding]]></category>
		<category><![CDATA[color]]></category>
		<category><![CDATA[consistency]]></category>
		<category><![CDATA[improve]]></category>
		<category><![CDATA[layout]]></category>
		<category><![CDATA[structure]]></category>
		<category><![CDATA[user experience]]></category>
		<category><![CDATA[user interface]]></category>

		<guid isPermaLink="false">http://www.webia.info/?p=513</guid>
		<description><![CDATA[Throughout their life people develop different patterns. These patterns are visible in how people interact with each other, actions they usually take for similar scenarios. Some develop tics. A tic is a spasmodic contraction of muscles that usually occurs in the face. People love patterns because patterns make them feel comfortable. Some sales people could [...]]]></description>
			<content:encoded><![CDATA[<p>Throughout their life people develop different patterns. These patterns are visible in how people interact with each other, actions they usually take for similar scenarios. Some develop tics. A tic is a spasmodic contraction of muscles that usually occurs in the face. People love patterns because patterns make them feel comfortable. Some sales people could develop a pattern in opening a discussion with someone else, a stranger, and could feel awkward if a chat with a new prospect doesn't go according to the usual plan.</p>
<p>Some love drinking coffee while reading the newspaper in the morning, and each morning they do the same thing. Programmers love having coke or energy drinks while they code while cops love their donuts. The list of habits and patterns is very long, and is not the goal of this article.</p>
<p>But if we love patterns, why almost every software out there is different than the one next to it? Why related sections on a site are different when they should have similar structure? Not having a consistent layout across a site, across a network of sites will damage user experience, because it will be harder for your visitors to go around the site developing habits.</p>
<h2>Consistency matters. Here's why</h2>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2009/09/mac_os_x.jpg"><img src="http://www.webia.info/wp-content/uploads/2009/09/mac_os_x.jpg" alt="Mac OS X screenshot" /></a></p>
<p>Take for example Apple's operating system OS X. Leopard is consistent across different areas and software installed on the platform uses the same visual elements, positioning of elements. Users therefor learn their habits faster and the user experience improves drastically because people know their way around the operating system.
</p>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2009/09/mac_os_x_snow.jpg"><img src="http://www.webia.info/wp-content/uploads/2009/09/mac_os_x_snow.jpg" alt="Mac OS X Snow Leopard screenshot" /></a></p>
<p>Further more, Snow Leopard, the new OS from Apple, didn't produce huge changes in user interface since original Leopard. The new version only improved the first one, while adding some new features. Slight changes do appear in the user interface, but they were placed in the right place, exactly where users expected them to be. Another good example is the iPhone's user interface, which contains a set of basic elements that are given to developers, and they use only those elements to build the structure of their apps. The direct result is whatever app you are using, be it a weather app or sending a text message, interacting with the phone is done in the same way.</p>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2009/09/iphone_ui.jpg"><img src="http://www.webia.info/wp-content/uploads/2009/09/iphone_ui.jpg" alt="iPhone UI screenshots" /></a></p>
<p>As I do not want to put Apple on a pedestal, Microsoft is consistent throughout their Office suite. Similar functions are placed in the same spots whether you're using Word, PowerPoint or Excel for example. Another good example is out of the IT world, into cars. All cars have the brakes, clutch and throttle in the same place, and all cars are to be driven on the right side of the road, with minor exceptions.</p>
<p>Google, doesn't do a really great job when it comes down to consistency. They do have consistency across different services they offer, but what I will talk about is Google's search engine and their translation service. While searching on Google you may misspell a few words. Should that happen, Google searches for your phrase but also makes suggestions for search phrases with proper grammar. What I don't understand is why such suggestions and corrections of my bad grammar don't happen while trying to translate something. You could hear a word on radio or on TV and you have no clue what it means. Moreover, you don't know exactly how to spell it, but you give your best. Then you hit translate, and the word appears in another language exactly the same. This is totally wrong especially because there's nothing that says that the word was not found. It is your own guess that the word you typed is badly written or doesn't really exist. Google does provide a tiny search link. But it is tiny and takes you away from the translation page. Poor user experience from Google.</p>
<h2>Consistency across the web: Envato</h2>
<p>We will first look upon Envato's websites network. They all share the same structure, all links are in the same place across all sites. Articles have same structure. The only difference between them is given by different color schemes.</p>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2009/09/psd_tuts.jpg"><img src="http://www.webia.info/wp-content/uploads/2009/09/psd_tuts.jpg" alt="psdtuts.com screenshot" /></a></p>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2009/09/vector_tuts.jpg"><img src="http://www.webia.info/wp-content/uploads/2009/09/vector_tuts.jpg" alt="vectortuts.com screenshot" /></a></p>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2009/09/cg_tuts.jpg"><img src="http://www.webia.info/wp-content/uploads/2009/09/cg_tuts.jpg" alt="cgtuts.com screenshot" /></a></p>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2009/09/audio_tuts.jpg"><img src="http://www.webia.info/wp-content/uploads/2009/09/audio_tuts.jpg" alt="audiotuts.com screenshot" /></a></p>
<h2>Consistency across the web: Nike</h2>
<p>The next stop will be another network having consistency across many sites: Nike. Same structure, different colors, awesome branding.</p>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2009/09/nike_women.jpg"><img src="http://www.webia.info/wp-content/uploads/2009/09/nike_women.jpg" alt="nike women screenshot" /></a></p>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2009/09/nike_football.jpg"><img src="http://www.webia.info/wp-content/uploads/2009/09/nike_football.jpg" alt="nike football screenshot" /></a></p>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2009/09/nike_basketball.jpg"><img src="http://www.webia.info/wp-content/uploads/2009/09/nike_basketball.jpg" alt="nike basketball screenshot" /></a></p>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2009/09/nike_soccer.jpg"><img src="http://www.webia.info/wp-content/uploads/2009/09/nike_soccer.jpg" alt="nike soccer" /></a></p>
<p>If you have any other examples or pointers please leave them in the comments section bellow. If you liked this article you can subscribe to the full content <a href="http://feeds2.feedburner.com/WebInternationalAwards" target="_new">rss feed</a> and stay updated as we post new information.</p>]]></content:encoded>
			<wfw:commentRss>http://www.webia.info/articles/consistency-key-element-in-extraordinary-ux/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Graceful flash degradation</title>
		<link>http://www.webia.info/articles/usability/graceful-flash-degradation/</link>
		<comments>http://www.webia.info/articles/usability/graceful-flash-degradation/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 14:18:00 +0000</pubDate>
		<dc:creator>Bogdan Pop</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[techniques]]></category>
		<category><![CDATA[usability]]></category>
		<category><![CDATA[degradation]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.webia.info/?p=487</guid>
		<description><![CDATA[
It has been quite some time since I last wrote an article here, and I hope you all enjoyed the summer and summer holiday. I read a lot of blogs each day and I must say that there's a decent amount of articles about javascript, content, and how to properly code a site when using [...]]]></description>
			<content:encoded><![CDATA[<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2009/09/uefa_flash.jpg"><img src="http://www.webia.info/wp-content/uploads/2009/09/flashplayerlogo.jpg" alt="flash player logo on artwork" /></a></p>
<p>It has been quite some time since I last wrote an article here, and I hope you all enjoyed the summer and summer holiday. I read a lot of blogs each day and I must say that there's a decent amount of articles about javascript, content, and how to properly code a site when using javascript. You have to be careful because of those people who disable javascript or use old browsers that don't have such features. However, I haven't seen any articles describing some short guidelines as to what you should do when developing a site in flash.</p>
<h2>Issues with flash developing</h2>
<p>The first issue that has to be taken into consideration here is that while many people have flash player installed, its version may be an older one, and the site or web app you are building with flash 10 may not work correctly, or at all on some people's computers. Moreover, there are individuals that don't have flash player installed, just like the ones without javascript. </p>
<h2>How to handle flash generated problems</h2>
<p>The easiest option would be to develop a html version of the site. Though this is ok, the costs of such a solution grow as the site grows. This is ok for small sites or sites that are not updated frequently. What happens when you have a big site, with content updated on a daily basis?</p>
<span id="more-487"></span>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2009/09/uefa_flash.jpg"><img src="http://www.webia.info/wp-content/uploads/2009/09/uefa_flash.jpg" alt="eufa.com screenshot" /></a></p>
<p>One interesting solution, which I definitely like is the one adopted by UEFA (Union of European Football Associations). Their website is not entirely flash, but has many flash sections. One of them is a content slider, which could have been built using javascript. They used flash and that is ok too, but how they fix search engine issue that come by using flash. How can people using mobile devices like the iPhone - which doesn't have flash - browse their website and read valuable content?</p>
<p>The solution is quite simple. UEFA's website displays all content headlines as plain text. Those headlines were previously bundled with images in the flash content slider. Moreover, the headlines appear in the same area of the site, leaving the layout uncrippled. Another important feature is that they also display a small button telling their visitors that if they want to fully enjoy the site they should install flash player. They also link to Adobe's download page.</p>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2009/09/uefa_non_flash.jpg"><img src="http://www.webia.info/wp-content/uploads/2009/09/uefa_non_flash.jpg" alt="uefa.com screenshot" /></a></p>
<p>UEFA does a great job making a well developed website, but they have their own pitfalls. During the UEFA Champions League and UEFA Europa League draws, which took place last week, their live coverage of the event had only flash versions, rendering blank pages for users without flash player. Mobile users had to make phone calls in order to find out the group of their favorite team.</p>
<p>A website that does a bad job about non flash user experience is <a href="http://www.vinuldenunta.ro" target="_new">vinuldenunta.ro</a> . Such users do see something other than a blank page. They are presented with a small paragraph which unfortunately isn't formatted in any way, leaving the impression the site is under construction. No information is provided regarding the cool flash version of the site that is hidden to them.</p>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2009/09/vinuldenunta.jpg"><img src="http://www.webia.info/wp-content/uploads/2009/09/vinuldenunta.jpg" alt="vinuldenunta.ro screenshot" /></a></p>
<h2>Pointers for better flash developing</h2>
<ul>
<li>1. If possible, provide a non flash version of the site</li>
<li>2. If important content is displayed within flash, make sure it is available for users that do not have flash player</li>
<li>3. Don't use flash for navigation, and if you do, provide a secondary navigation menu using html</li>
<li>4. If you only have flash version, make sure you let non flash users know about that</li>
</ul>
<p>The above are just some basic pointers, but sticking to them will insure a high quality website. If you have any other examples or pointers please leave them in the comments section bellow. If you liked this article you can subscribe to the full content <a href="http://feeds2.feedburner.com/WebInternationalAwards" target="_new">rss feed</a> and stay updated as we post new information.</p>]]></content:encoded>
			<wfw:commentRss>http://www.webia.info/articles/usability/graceful-flash-degradation/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

