<?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; layout</title>
	<atom:link href="http://www.webia.info/category/articles/layout/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>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>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>What not to do in mobile web design (#2)</title>
		<link>http://www.webia.info/articles/usability/what-not-to-do-in-mobile-web-design-2/</link>
		<comments>http://www.webia.info/articles/usability/what-not-to-do-in-mobile-web-design-2/#comments</comments>
		<pubDate>Mon, 15 Jun 2009 08:12:47 +0000</pubDate>
		<dc:creator>Bogdan Pop</dc:creator>
				<category><![CDATA[design]]></category>
		<category><![CDATA[layout]]></category>
		<category><![CDATA[usability]]></category>
		<category><![CDATA[don't do]]></category>
		<category><![CDATA[havris.com]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[not to do]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.webia.info/?p=391</guid>
		<description><![CDATA[This is a second article of a series of articles about what one developer, or for that matter, a designer, shouldn't do in mobile web design. This second article also treats some serious usability issues, so the problems described in this article shouldn't be used on any site, not just on website's versions targeted to [...]]]></description>
			<content:encoded><![CDATA[<p>This is a second article of a series of articles about what one developer, or for that matter, a designer, shouldn't do in mobile web design. This second article also treats some serious usability issues, so the problems described in this article shouldn't be used on any site, not just on website's versions targeted to mobile devices.</p>
<h2>Similar articles</h2>
<ul>
<li><a href="http://www.webia.info/articles/usability/what-not-to-do-in-mobile-web-design" target="_new">What not to do in mobile web design (1st post of the series)</a></li>
<li><a href="http://www.webia.info/articles/usability/what-not-to-do-in-form-design" target="_new">What not to do in form design (related article)</a></li>
</ul>
<h2>The issue</h2>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2009/06/havris_com_main.jpg" title="Havris's bad homepage design. 1 link out of 3 buttons."><img src="http://www.webia.info/wp-content/uploads/2009/06/havris_com_main.jpg" alt="havris.com homepage screenshot" /></a></p>
<p>I ended up on <a href="http://www.havris.com/" target="_new">Havris's</a> website by chance. A client to whom my company has provided an SSL certificate had some issues, and after fixing that issue I wanted to check their site to see if the company that develops their website installed the SSL certificate correctly. If you see, they have three boxes, labeled as "Services", "Portfolio" and "Contact &#038; Support". Judging by their design, you would say those labels are in fact buttons that get you to detailed pages about their services, their work and providing easier, multiple ways for you to contact them. But they don't! Out of all three labels, only the "Portfolio" is a link, the rest are just plain text.</p>
<span id="more-391"></span>
<p>In terms of usability this is really bad as it confuses the user. I sure was confused until I started looking around an hovering with my mouse some elements. This happened while I was on my macbook pro. However, the first time I went to the site was using my iPhone. While on iPhone, you do not have the ability to hover. It would be great if you could put your finger close to the touchscreen and produce a hover effect, but for now, iPhones don't do that. So, while browsing the site with my iPhone, I simply couldn't click anywhere. What intrigues me is that I wasn't even able to click the "profile" link, which really is a link.</p>
<p>See the screenshot? See the difference between the "portfolio" link and the other 2 labels? Neither do I. So make sure that in your designs users can differentiate between the two. Havris also has that bullet/star on top of the three boxes, which unfortunately doesn't go anywhere either. Ok, so I get a flat fee for simple website, but which is the flat fee, and what do you mean by simple website?</p>
<h2>And there's even more bad stuff</h2>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2009/06/havris_com_second.jpg" title="Havris's bad portfolio design. No link out of 4 buttons."><img src="http://www.webia.info/wp-content/uploads/2009/06/havris_com_second.jpg" alt="havris.com portfolio screenshot" /></a></p>
<p>The above issues were found only on the homepage, but wait till you get to the other page that exists: the <a href="http://www.havris.com/portfolio.php" target="_new">portfolio</a>. The portfolio page contains three small buttons in the upper right corner of the page. The bad thing is that those buttons have no functionality. You cannot go back to the homepage, you cannot click the "Services" link nor can you click the mandatory "Contact" link. Support is not really necessary as you cannot order a site in the first place. Moreover, the slider used to showcase their project has no decent effects. Finally, their logo in the portfolio page is not a link to the site's homepage. That is really bad. A detailed explanation and examples of better, enhanced home link buttons can be found in our series of articles: <a href="http://www.webia.info/articles/usability/better-home-link-buttons" target="_new">Better home link buttons</a>, and <a href="http://www.webia.info/articles/usability/better-home-link-buttons-2" target="_new">Better home link buttons (#2)</a>.</p>
<p>Overall, the site has an awful turnout. It looks like it was made by amateurs. If you liked this article, which is part of a series of articles on mobile web design and usability, 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/what-not-to-do-in-mobile-web-design-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What not to do in mobile web design!</title>
		<link>http://www.webia.info/articles/usability/what-not-to-do-in-mobile-web-design/</link>
		<comments>http://www.webia.info/articles/usability/what-not-to-do-in-mobile-web-design/#comments</comments>
		<pubDate>Mon, 13 Apr 2009 20:24:55 +0000</pubDate>
		<dc:creator>Bogdan Pop</dc:creator>
				<category><![CDATA[design]]></category>
		<category><![CDATA[layout]]></category>
		<category><![CDATA[usability]]></category>
		<category><![CDATA[advice]]></category>
		<category><![CDATA[do]]></category>
		<category><![CDATA[don't]]></category>
		<category><![CDATA[mobile design]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.webia.info/?p=288</guid>
		<description><![CDATA[Mobile web design and development should be easy these days. We have iPhones, Androids and Blackberries which make our lives a lot easier. However, some web developers out there really cannot handle the pressure of mobile development and they do wrong big time.
What not to do! Livescore's way.

I am a big football fan. European football [...]]]></description>
			<content:encoded><![CDATA[<p>Mobile web design and development should be easy these days. We have iPhones, Androids and Blackberries which make our lives a lot easier. However, some web developers out there really cannot handle the pressure of mobile development and they do wrong big time.</p>
<h2>What not to do! Livescore's way.</h2>
<p class="imgpreview"><a href="" target="_self" class="showlivescore.com"><img src="http://www.webia.info/wp-content/uploads/2009/04/livescore_com.jpg" alt="livescore.com iPhone screenshot"/></a></p>
<p>I am a big football fan. European football fan. Therefore, I use on a daily basis <a href="http://www.livescore.com" target="_new">livescore.com</a>. Livescore.com started out offering live score feeds for football games, but they now do that for tennis, hockey and their latest addition, basketball. I just love their site, how it looks, how it works, and every time I am out in a pub watching a game, I need to check out the scores. I do that using my iPhone. But I really don't like to do that. I don't like it because I am redirected to the iPhone (not mobile) version of the site. The design of the mobile version is quite ok, it looks like a iPhone web app, remember those? I don't like it because it is hard to switch from one country to another, see in depth details of some games etc. The iPhone version is kluged with javascript, and it moves really slow! I wouldn't even give a try to this mobile version if I was not obliged to do so. That's right, they do not provide any ways to get to the full site on your iPhone. Whatever you do you're redirected to the mobile version. Moreover, each sliding animation (they use slides for navigation) load twice for each action, not just once.</p>
<span id="more-288"></span>
<p>The only good thing about livescore.com's mobile version is that they do have landscape mode. The mobile version doesn't crack when you tilt your iPhone. They chose a liquid layout which works fine under these circumstances.</p>
<h2>What not to do! Antena3's way.</h2>
<p><a href="http://www.antena3.ro" target="_self">Antena3.ro</a> is the website of a news television in Romania. I only use their live online videofeed while on my mac. Last week while traveling I heard something on the radio and I really needed to check out some details. Therefore, I went to their site, and I was redirected to the mobile version. If livescore.com received such criticism while they provide a working site, Antena 3 is going down!</p>
<p class="imgpreview"><a href="" target="_self" class="showlivescore.com"><img src="http://www.webia.info/wp-content/uploads/2009/04/antena3.jpg" alt="antena3.ro mobile screenshot"/></a></p>
<p>First of all, try to style that page a bit. I don't like newspapers, that's why I get news via my Iphone guys! Some of you might say that not styling the mobile version means less traffic, and faster loading times. That is true, but if you want that do not place a big add on the top of the mobile version page. I really do not want to win 5 Sony Ericssons.</p>
<p>Under the big ad, they show up latest news. They are displayed as a list containing a title, a small thumbnail, and less than 50 chars of preview from the actual news text. They display the latest 10 news, followed by a categories list, so that you can browse news in the domain you wish for. This is ok, and it also works in landscape mode.</p>
<p>But then, you want to see details, not just titles. Naturally, you click on a headline to see the full article. You get the full article which may or may not have links within its text. I unfortunately found one, and I wanted to see the related article. Guess what happened? I clicked the link, which pointed to the main site, not the mobile version. When the page loaded, I was instantly redirected to the mobile version, but not to the page where the article I was looking for resided. I was taken to the homepage. So basically, you cannot read more than 10 articles. No comment!</p>
<p>Moreover, while navigating through different categories and different titles, I ended up on a page that didn't exist. I was asked to use the menu positioned above, which is in fact on the bottom of the page! I could have gone to the home page or search. While searching for a keyword, I was redirected to the homepage. Didn't the search find any results? I have no idea! Awful user experience.</p>
<h2>What to do! Google's way.</h2>
<p>When I first tried out Google on my Iphone, I was constantly (every time, actually) redirected to the mobile version of the google search page. However, I wished to access iGoogle as I do on my mac, and unfortunately was not able to do so. I really do not remember how long it took them to do this, but they fixed the issue.</p>
<p>Google now provides their mobile users by default with the mobile version of the site, but you have a switching link in the footer of the site. As you switch from Google in your own language to Google.com in English, you can switch from mobile to standard versions, which I like most. Great. Well done guys!</p>
<p>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/what-not-to-do-in-mobile-web-design/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

