<?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; usability</title>
	<atom:link href="http://www.webia.info/category/articles/usability/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.webia.info</link>
	<description></description>
	<lastBuildDate>Thu, 09 Sep 2010 06:58: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>Keep it simple</title>
		<link>http://www.webia.info/articles/usability/keep-it-simple/</link>
		<comments>http://www.webia.info/articles/usability/keep-it-simple/#comments</comments>
		<pubDate>Tue, 01 Jun 2010 08:00:33 +0000</pubDate>
		<dc:creator>Bogdan Pop</dc:creator>
				<category><![CDATA[usability]]></category>
		<category><![CDATA[effective]]></category>
		<category><![CDATA[fast]]></category>
		<category><![CDATA[keep]]></category>
		<category><![CDATA[kiss]]></category>
		<category><![CDATA[professional]]></category>
		<category><![CDATA[satisfy]]></category>
		<category><![CDATA[simple]]></category>

		<guid isPermaLink="false">http://www.webia.info/?p=1649</guid>
		<description><![CDATA[
Whether you're developing a webapp, a website, some native software or a simple installer, keep it simple and straightforward. We barely have time for anything these days, and effective solutions that help us doing what we need to do fast, without error will win over pretty much anything else.


This concept applies to web forms, navigation, [...]]]></description>
			<content:encoded><![CDATA[<p>
Whether you're developing a webapp, a website, some native software or a simple installer, keep it simple and straightforward. We barely have time for anything these days, and effective solutions that help us doing what we need to do fast, without error will win over pretty much anything else.
</p>
<p>
This concept applies to web forms, navigation, software options, and more. The faster the users get things done, the more satisfied they will feel, they'll use your solution even more and refer others to it. This post will be best suited in a thoughts / tumblr blog, but I figured it may get in here as well. 
</p>
<h2>Inspiration</h2>
<p>
This post was inspired from the recent Windows encounters I've had. Remember the post on <a href="http://www.webia.info/articles/usability/key-usability-in-web-forms">web forms usability</a> published just a while ago? Well, while installing the Microsoft Office Suite downloaded after using that faulty web form, I got a new installation wizard out of the blue, which I didn't ask for.
</p>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2010/05/select_components_to_install.jpg" title="Microsoft installer asking to select unique component to be installed"><img src="http://www.webia.info/wp-content/uploads/2010/05/select_components_to_install.jpg" alt="Microsoft installer asking to select unique component to be installed" /></a></p>
<p>
For some reason, I was asked to install Business contact Manager for Outlook Express 2007. I have no idea what that is, but I assume what it's used for. Bottom line is I don't need it. On top of that is the really bad installer.
</p>
<p> Let's assume someone wants to actually install it. The installer starts and shows one component that can be installed. The one I want. Why would you not simply let me get through with the process and require me to select the component to be installed. After all, moments ago I double clicked to install it? Why confirm that again? 
</p>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2010/05/select_components_to_install_next.jpg" title="Microsoft installer with enabled next button only after unique component is selected"><img src="http://www.webia.info/wp-content/uploads/2010/05/select_components_to_install_next.jpg" alt="Microsoft installer with enabled next button only after unique component is selected" /></a></p>
<p>
What's even worse is that I cannot click the Next button until I select the unique component. Moreover, there isn't a "finish" installation button. It's a "Next" step button. I don't want to waste any more steps with this issue. Just let me get on with it.
</p>
<p>
To conclude, whatever you're doing, try to keep it simple and straightforward for your users. Don't frustrate them with never ending jibberish chat.
</p>]]></content:encoded>
			<wfw:commentRss>http://www.webia.info/articles/usability/keep-it-simple/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Key usability in web forms</title>
		<link>http://www.webia.info/articles/usability/key-usability-in-web-forms/</link>
		<comments>http://www.webia.info/articles/usability/key-usability-in-web-forms/#comments</comments>
		<pubDate>Tue, 25 May 2010 13:00:38 +0000</pubDate>
		<dc:creator>Bogdan Pop</dc:creator>
				<category><![CDATA[usability]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[fields]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[guidelines]]></category>
		<category><![CDATA[mandatory]]></category>
		<category><![CDATA[optional]]></category>
		<category><![CDATA[practice]]></category>
		<category><![CDATA[required]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.webia.info/?p=1636</guid>
		<description><![CDATA[

Two of the most popular articles published here deal with web forms. The first one is around the theoretical aspects of web forms while the second one resides along the practical issues, coding and validating web forms. This article blends some concepts from both articles and showcases a key error that mustn't be in your [...]]]></description>
			<content:encoded><![CDATA[<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2010/05/forms_usability_required_big.png" title="Microsoft's form displaying errors for required / not required fields. Who knows?"><img src="http://www.webia.info/wp-content/uploads/2010/05/forms_usability_required_small.jpg" alt="Microsoft's form displaying errors for required / not required fields. Who knows?" /></a></p>
<p>
Two of the most popular articles published here deal with web forms. The first one is around the <a href="http://www.webia.info/articles/usability/forms-cant-live-with-them-cant-live-without-them/">theoretical aspects of web forms</a> while the second one resides along the practical issues, <a href="http://www.webia.info/articles/usability/impressive-web-forms-from-coding-to-validation/">coding and validating web forms</a>. This article blends some concepts from both articles and showcases a key error that mustn't be in your web forms.
</p>
<h2>The issues with required fields</h2>
<p>
The issue with required fields is that there shouldn't be any required fields on a web form. Don't place asterisks to label required fields. Nobody follows that pattern, though most users expect a field to be required if it has one asterisk appended to its label. If you have a web form that requires user's email, password, first and last names, don't put asterisks or any other messages. Just put the inputs in the form and the user will fill them.
</p>
<p>
Moreover, if you have those fields, don't place an asterisk only next to email and password and expect users to input their names as well. That will never happen! Following this pattern, after the user hits the submit button, don't display an error message telling them that the name fields are required as well, if you didn't point that out in the first place. This is usually something that will make visitors leave your website and never use your form, which was the primary goal for them upon arriving at that page.
</p>
<h2>That is total failure! Your mistake, not your user's!</h2>
<p>
Time to guess who has web forms with such flaws. It's Microsoft! The same company that has .exe executable download managers which users need to run to download any of their software. Mac users need to run them as well to download their operating system, for example, if they wish to switch to Windows, or use it virtually. But that's another story.
</p>
<h2>The moral</h2>
<p>
From time to time, I unfortunately need to use Microsoft Office and other Windows native software. Not my option though. While trying to download a trial version of the Office suite, I was asked to sign up on Microsoft's website. The form asked for my email, my desired password, first and last names, and my country. The first two we're marked as mandatory fields, while the rest weren't. The country field was a preselected select field, which I had nothing else to do but update.
</p>
<p>
After pressing the submit button, I wasn't taken to a download page. Instead, I was shown a couple of errors I've done. I haven't inputted any information in my name fields. But I didn't know I needed to. Thank god for Microsoft that the bid I was working on required specific documents (.docs) and I really needed to proceed, otherwise that would have been the end of my journey on their website.
</p>
<h2>Conclusion</h2>
<p>
Try to strip down the fields of your web forms. Not the required ones, but all fields. Don't ask for unnecessary information. Ask only mandatory information, and don't label it as mandatory. If your form is simple and short, users would be delighted to input what you're asking for.
</p>]]></content:encoded>
			<wfw:commentRss>http://www.webia.info/articles/usability/key-usability-in-web-forms/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Never deceive your visitors! based on a true story&#8230;</title>
		<link>http://www.webia.info/articles/usability/never-deceive-your-visitors-based-on-a-true-story/</link>
		<comments>http://www.webia.info/articles/usability/never-deceive-your-visitors-based-on-a-true-story/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 15:00:20 +0000</pubDate>
		<dc:creator>Bogdan Pop</dc:creator>
				<category><![CDATA[usability]]></category>
		<category><![CDATA[deceive]]></category>
		<category><![CDATA[honest]]></category>
		<category><![CDATA[pay]]></category>
		<category><![CDATA[payment]]></category>
		<category><![CDATA[price]]></category>
		<category><![CDATA[product]]></category>
		<category><![CDATA[progress bar]]></category>
		<category><![CDATA[service]]></category>

		<guid isPermaLink="false">http://www.webia.info/?p=1431</guid>
		<description><![CDATA[
Just the other day I stumbled upon an unexpected ad on a television's website. The add was about IQ tests and pointed to a site where you could take one. I clicked and was taken to the website which had a thorough IQ test. At least their about page stated so. Bottom line is that [...]]]></description>
			<content:encoded><![CDATA[<p>
Just the other day I stumbled upon an unexpected ad on a television's website. The add was about IQ tests and pointed to a site where you could take one. I clicked and was taken to the website which had a thorough IQ test. At least their about page stated so. Bottom line is that this test looked serious, or at least it was more serious than the ones I've seen over the years. I've decided to take it.
</p>
<p>
There were no time penalties, a nice progress bar indicated where you were throughout the entire testing. Overall it was a nice experience, which seemed close to perfection. Oh but was I wrong! I don't know exactly how many questions were in there, but I think they were more than 50. 
</p>
<p>
After roughly 30 minutes, I completed the task. I was asked to input my name and email and hit submit to have my results emailed to me. I knew ads on such a high traffic television site couldn't be cheap, and this wouldn't be a scam, so I went on and put in my details and clicked the submit button.
</p>
<p>
The next page was a disaster, completely ruining my experience, making me bounce off the website and write this article. Why? The thank you page didn't contain my test result. Instead it contained 2 phone numbers to which I could send a 5 Euro SMS to pay for the results they just said would be emailed to me. This was the first point in the entire process when I saw it is a paid service. After spending 30 minutes! And no, I won't pay and I didn't pay.
</p>
<h2>Let your users know your service isn't free right from the get go!</h2>
<p>But would I've paid if I knew from the start it's not a free test? Probably! They lost a happy customer in added time, and they probably lost and will lose many more with this stupid system.</p>
<h2>Tips to improve your paid service sign up process</h2>
<ol>
<li>Always let your users know it's a paid service from the moment they arrive to your page</li>
<li>Payment page should never be the last one of the signup process, unless users know from start how much the product or service costs</li>
<li>If the signup process is lengthy provide visual progress bars</li>
<li>Never cheat with these progress bars to fool users into thinking they're close to finish line when they're not</li>
</ol>
<h2>Conclusion</h2>
<p>
Always let your users know if they can use your paid service, and let them no before they start using it. Doing so afterward will probably make you loose almost every client. Always be honest about your offered service and price because at the slightest misinformation your customers will go straight to your competitors.
</p>
<p>
If you have any similar experiences or any other tips please share them in the comments. Please share the link with 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>]]></content:encoded>
			<wfw:commentRss>http://www.webia.info/articles/usability/never-deceive-your-visitors-based-on-a-true-story/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Impressive web forms. From coding to validation!</title>
		<link>http://www.webia.info/articles/usability/impressive-web-forms-from-coding-to-validation/</link>
		<comments>http://www.webia.info/articles/usability/impressive-web-forms-from-coding-to-validation/#comments</comments>
		<pubDate>Tue, 23 Mar 2010 17:37:00 +0000</pubDate>
		<dc:creator>Bogdan Pop</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[layout]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[usability]]></category>
		<category><![CDATA[client]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[experience]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[validation]]></category>
		<category><![CDATA[xhtml]]></category>

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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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

		<guid isPermaLink="false">http://www.webia.info/?p=1212</guid>
		<description><![CDATA[

Scrolling wheels are usually used to navigate up and down or left to right on a page that is larger than the default viewport of the browser. However, by using JavaScript one can enhance the user interface of a site or webapp and reprogram, if I may say it like this, the default behavior of [...]]]></description>
			<content:encoded><![CDATA[<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2010/03/joao_andrade.jpg" title="Screenshot of João Andrade's website header "><img src="http://www.webia.info/wp-content/uploads/2010/03/joao_andrade.jpg" alt="Screenshot of João Andrade's website header" /></a></p>
<p>
Scrolling wheels are usually used to navigate up and down or left to right on a page that is larger than the default viewport of the browser. However, by using JavaScript one can enhance the user interface of a site or webapp and reprogram, if I may say it like this, the default behavior of the scrolling wheel.
</p>
<h2>Good scenarios</h2>
<p>
If a web document contains textareas or block elements with overflow set to auto and the content inside these elements extends the area of the element itself a scrolling bar will appear, be it horizontal or vertical. By default, users will be able to scroll inside these elements by pointing the mouse inside the element's borders and use the scrolling wheel. If positioned outside the element when using the scrolling wheel the entire page will scroll. This is a good feature. Moreover, it is what users expect to achieve given these circumstances. And this works without developers doing anything.
</p>
<h2>Bad scenarios</h2>
<p>
Many modern websites use inline slideshows or sliders to showcase more content in less space, from photo galleries to product features and more. However some sites enhance these sliders in such a bad way that they completely screw up user experience. Check out <a href="http://www.joaoandrade.com.br/" target="_new">João Andrade's website</a> and try to scroll down to the bottom of the page where a contact form is located &#8212; contact form which is the selling point of his website. Unfortunately you get stuck in the header of the site because there's an enhanced "awesome" slider which moves to next or previous slides based on how you use the scrolling wheel.
</p>
<p>
This feature is bad because it redirects the default behavior of the scrolling wheel away from the page scrolling bar, and if you're not quick in reactions you'd think that the site is buggy. This feature would probably be ok if the slider would be properly delimited from the rest of the page and the slider's numeric controls would stand out, just as a textarea or block element that overflow delimit themselves nicely due to the scrolling bar that pops out near the right border of the element. Currently, the slider on João Andrade's website blends in beautifully inside the page.
</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/tutorials/make-your-own-jquery-slider-using-xml/" target="_self">Make your own jQuery slider using XML</a></li>
<li>2. <a href="http://www.webia.info/reviews/the-smashing-book-is-indeed-smashing/" target="_self">The Smashing Book is indeed… Smashing!</a></li>
<li>3. <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>4. <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>5. <a href="http://www.webia.info/articles/consistency-key-element-in-extraordinary-ux/" target="_self">Consistency. Key element in extraordinary UX</a></li>
<li>6. <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/enhancing-ui-with-scrolling-events-good-or-bad/feed/</wfw:commentRss>
		<slash:comments>0</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>Buttons and usability</title>
		<link>http://www.webia.info/articles/usability/buttons-and-usability/</link>
		<comments>http://www.webia.info/articles/usability/buttons-and-usability/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 13:00:22 +0000</pubDate>
		<dc:creator>Bogdan Pop</dc:creator>
				<category><![CDATA[usability]]></category>
		<category><![CDATA[action]]></category>
		<category><![CDATA[button]]></category>
		<category><![CDATA[cancel]]></category>
		<category><![CDATA[close]]></category>
		<category><![CDATA[delete]]></category>
		<category><![CDATA[destructive]]></category>
		<category><![CDATA[link]]></category>
		<category><![CDATA[x]]></category>

		<guid isPermaLink="false">http://www.webia.info/?p=1043</guid>
		<description><![CDATA[The other day I was talking to a friend about destructive actions in web forms, web apps, or any kind of apps for that matter. With any destructive action such as cancel, exit or delete comes great responsibility for the developer.
Delete links and buttons
You're responsible for each user who's frustrated because they accidentally clicked your [...]]]></description>
			<content:encoded><![CDATA[<p>The other day I was talking to a friend about destructive actions in web forms, web apps, or any kind of apps for that matter. With any destructive action such as cancel, exit or delete comes great responsibility for the developer.</p>
<h2>Delete links and buttons</h2>
<p>You're responsible for each user who's frustrated because they accidentally clicked your delete button, and there's no way to restore their deleted work. This problem usually resides around web apps because only a few web apps offer undo / redo behaviors. 
</p>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2010/02/btn_usability_mailchimp.jpg" title="Mailchimp asks for delete confirmation. To make things worse, popup takes ages to load"><img src="http://www.webia.info/wp-content/uploads/2010/02/btn_usability_mailchimp.jpg" alt="mailchimp delete action confirmation question screenshot" /></a></p>
<p>
<a href="http://www.mailchimp.com">Mailchimp</a> asks for delete confirmation, as you can see in the above screenshot. To make things worse, the popup takes ages to load, so the interface doesn't go as smooth as you'd want. Moreover, the confirm and cancel buttons are in close proximity. What if I accidentally click delete, than accidentally click confirm?
</p>
<h2>Cancel buttons in forms</h2>
<p>
The same goes with forms and their cancel buttons. Many forms have cancel buttons although I don't see their point. If you wish to cancel what you've done in a form, you simply go to another page or hit the X button.
</p>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2010/02/btn_fivecentstand_cancel.jpg" title="Five Cent Stand's form looks as it has one 'submit clear' button as opposed to two"><img src="http://www.webia.info/wp-content/uploads/2010/02/btn_fivecentstand_cancel.jpg" alt="fivecentstand.com forms with usability issues as submit and clear buttons cannot be distinguished" /></a></p>
<p>However, some insist and put a cancel button in the form. Moreover, they don't just put it in a remote area of the form, they put it right next to the submit button. This inevitably leads to users accidentally clicking it instead of the submit button, which means even more frustrated users.
</p>
<p>
As you can see in the screen above, <a href="http://www.fivecentstand.com/">Five Cent Stand</a> exaggerated with their creativity. Of course, their form is lovely, but can you see how close and similar are the send and clear buttons? You can barely see there's two distinct buttons. Really, really bad solution.
</p>
<h2>X or close buttons</h2>
<p>
Then there's the X (close) button which a few years ago was used only in desktop apps. Since the new rich user interfaces available on the web, a large number of web apps have lots of windows, and you guessed it, X buttons. The problem is nobody asks or tests if the clicks on these buttons are accidental or not. Making such check ups would be hard. And if you can't, you should check with the user if they meant it, which leads to our next problem. 
</p>
<p>
What if we asked users if they really like to perform that destructive action (X, delete, cancel) or not? This sounds so Windows right? Moreover, this would frustrate and irritate even more users than before.
</p>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2010/02/btn_windows_sure.jpg" title="Microsoft word asking if you really want to quit. Yes I DO!"><img src="http://www.webia.info/wp-content/uploads/2010/02/btn_windows_sure.jpg" alt="Microsoft word asking if you really want to quit" /></a></p>
<p>
The percentage of users actually wanting to click those buttons is way higher than those who do it by accident. This means they'll get pissed of with you for asking them for confirmation all the time. 
</p>
<h2>Is there a solution ?</h2>
<p>
It has to be, and here are some suggestions I thought might work. Let's start with the X button. One click may be unintended. How about a double click? I don't think that one could double click by accident. Even if that happened it would be just one user not plenty of them! The overall experience of almost everybody would definitely improve.
</p>
<p>
One solution for the forms canceling button would be placing it somewhere remote, far from the submit button, and styling it differently. What about delete buttons? A solution I think could work great is inspired from the Apple iPhone/iPod collection.
</p>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2010/02/btn_iphone.jpg" title="iPhone's slide to unlock and slide to turn on/off controls"><img src="http://www.webia.info/wp-content/uploads/2010/02/btn_iphone.jpg" alt="iPhone's slide to unlock and slide to on/off controls" /></a></p>
<p>
What if we developed delete and cancel buttons in a "slide to delete" fashion? Clicking them won't do any harm, but clicking and sliding for 30 pixels or so would trigger the event? Now wouldn't that please anyone?
</p>
<h2>Feedback</h2>
<p>Please share your thoughts on this topic in the comments section. 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/buttons-and-usability/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>The change is here. Hover events come to mobile devices</title>
		<link>http://www.webia.info/articles/usability/the-change-is-here-hover-events-come-to-mobile-devices/</link>
		<comments>http://www.webia.info/articles/usability/the-change-is-here-hover-events-come-to-mobile-devices/#comments</comments>
		<pubDate>Tue, 02 Feb 2010 08:02:00 +0000</pubDate>
		<dc:creator>Bogdan Pop</dc:creator>
				<category><![CDATA[usability]]></category>
		<category><![CDATA[click]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[devices]]></category>
		<category><![CDATA[experience]]></category>
		<category><![CDATA[hover]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[ui]]></category>
		<category><![CDATA[user]]></category>
		<category><![CDATA[ux]]></category>

		<guid isPermaLink="false">http://www.webia.info/?p=1049</guid>
		<description><![CDATA[
I think that everyone knows that awesome YouTube movie about technology and how things that we learn today will become obsolete in 6 months or maximum 1 year. Well, when I published the hover behavior article just a few days ago, I certainly didn't think what I advised there will become obsolete so fast. I [...]]]></description>
			<content:encoded><![CDATA[<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2010/02/hover_mobile_1.jpg" title="Functionalities diagram of hover feature for mobile devices"><img src="http://www.webia.info/wp-content/uploads/2010/02/hover_mobile_1.jpg" alt="Functionalities diagram of hover feature for mobile devices" /></a></p>
<p>I think that everyone knows that awesome YouTube movie about technology and how things that we learn today will become obsolete in 6 months or maximum 1 year. Well, when I published the hover behavior article just a few days ago, I certainly didn't think what I advised there will become obsolete so fast. I mean, I didn't see hover behavior coming to mobile devices this soon. Having this said, before going on with this article you should read the first <a href="http://www.webia.info/articles/usability/should-i-use-on-hover-behavior/" target="_new">article on hover events</a>.</p>
<p>
Apple has been granted a patent which has a mind blowing description, because it tackles proximity based systems and methods. What are those you may ask? Proximity methods are methods that a device can use to detect if there's an object placed in close proximity to its surface. Like a finger pointing above the iPhone's touch screen. Such method would also include performing an action if such an object is sensed. 
</p>
<p>
Basically, this describes hovering events triggered by fingers, not just one finger. Apple has multitouch interfaces so why shouldn't they have a similar multihover event? At first hand, having such a feature in an iPhone, iPad or iPod would be great, because all the issues I described in the first article on this topic would disappear!
</p>
<h2>But would they?</h2>
<p>
No they don't! In fact, such a feature in mobile devices would only complicate the situation, because users could easily trigger lots of hover events simultaneously on a web page or web app. This has never been thought of and web developers have never taken this into consideration as PCs don't have multiple mouse pointers. This means there's no protection in websites against such worst case scenarios. Imagine a user viewing a drop down navigation menu that displays multiple menus in the same time. Imagine what their reaction would be, especially if the scenario happened by accidental hovering and the user would be taken by surprise. I also don't think that such a menu would be easy to use.
</p>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2010/02/hover_mobile_2.jpg" title="Description of features of a tablet device app"><img src="http://www.webia.info/wp-content/uploads/2010/02/hover_mobile_2.jpg" alt="Description of features of a tablet device app" /></a></p>
<p>Such a new technology would technically fix the hovering issues of mobile devices, but would also trigger new ones, like the scenario described above, and would also give us power to create even greater interfaces by using multihover events. How cool would it be to point your finger to a product or pinch without touching the device to pop out details, and then click to buy it? 
</p>
<p>
Here's a link to the <a href="http://patft.uspto.gov/netacgi/nph-Parser?Sect1=PTO2&#038;Sect2=HITOFF&#038;p=1&#038;u=%2Fnetahtml%2FPTO%2Fsearch-bool.html&#038;r=3&#038;f=G&#038;l=50&#038;co1=AND&#038;d=PTXT&#038;s1=%22Apple+Inc%22&#038;OS=%22Apple+Inc%22&#038;RS=%22Apple+Inc%22" target="_new">patent</a> (Granted Patent 7,653,883, originally filed in Q3 2005 by Steve Hotelling, Duncan Robert Kerr, Bas Ording, Jonathan Ive, Peter Kennedy, Anthony Fadell and Jeffrey Robbin). 
</p>
<h2>Feedback</h2>
<p>Please share your thoughts on this topic in the comments section. 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/should-i-use-on-hover-behavior/" target="_new">Should I use on hover behavior?</a></li>
<li>2. <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>3. <a href="http://www.webia.info/articles/consistency-key-element-in-extraordinary-ux/" target="_new">Consistency. Key element in extraordinary UX</a></li>
<li>4. <a href="http://www.webia.info/articles/code/enhance-your-clients-list-with-jquery-goodness/" target="_new">Enhance your clients list page with jQuery goodness</a></li>
</ul>]]></content:encoded>
			<wfw:commentRss>http://www.webia.info/articles/usability/the-change-is-here-hover-events-come-to-mobile-devices/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Should I use on hover behavior?</title>
		<link>http://www.webia.info/articles/usability/should-i-use-on-hover-behavior/</link>
		<comments>http://www.webia.info/articles/usability/should-i-use-on-hover-behavior/#comments</comments>
		<pubDate>Sat, 30 Jan 2010 06:59:18 +0000</pubDate>
		<dc:creator>Bogdan Pop</dc:creator>
				<category><![CDATA[usability]]></category>
		<category><![CDATA[click]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[experience]]></category>
		<category><![CDATA[hover]]></category>
		<category><![CDATA[ui]]></category>
		<category><![CDATA[user]]></category>
		<category><![CDATA[ux]]></category>

		<guid isPermaLink="false">http://www.webia.info/?p=1007</guid>
		<description><![CDATA[

Yes, you should! Why not? After all, you could really enhance your user interface. However, using such a behavior could also tear apart user experiences, especially if your visitors are using mobile devices like the HTC Touch, the iPhone or the newly released iPad. Such devices unfortunately cannot "feel" your finger above the screen so [...]]]></description>
			<content:encoded><![CDATA[<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2010/01/themeforest_marketplaces.jpg" title="ThemeForest marketplace switch triggered"><img src="http://www.webia.info/wp-content/uploads/2010/01/themeforest_marketplaces.jpg" alt="ThemeForest dot net screenshot" /></a></p>
<p>
Yes, you should! Why not? After all, you could really enhance your user interface. However, using such a behavior could also tear apart user experiences, especially if your visitors are using mobile devices like the HTC Touch, the iPhone or the newly released iPad. Such devices unfortunately cannot "feel" your finger above the screen so there's no hovering triggered in their browsers.
</p>
<p>
Before choosing hover events in your websites or webapps you should probably check how much of your site's visitors are represented by mobile users. If the percentage is decent, I wouldn't use hovering and switch instead to the traditional click. <a href="http://www.themeforest.net/" target="_new">Envato's marketplaces</a> have been featured on Webia before for their awesome <a href="http://www.webia.info/articles/consistency-key-element-in-extraordinary-ux/" target="_new">consistency</a> across all websites, which was a good thing.
</p>
<p>
I am about to talk about a slightly bad thing on Envato's marketplace sites. Each of them has a categories button just below the logo, which if hovered with a mouse expands and shows popular categories. Clicking on such a category will redirect you to that category's dedicated page, while clicking the categories top button will trigger nothing.
</p>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2010/01/themeforest_categories_btn.jpg" title="ThemeForest's categories menu triggered by hover on PC"><img src="http://www.webia.info/wp-content/uploads/2010/01/themeforest_categories_btn.jpg" alt="ThemeForest's categories menu triggered by hover on PC" /></a></p>
<p>
Now that's ok if you're using a computer, notebook or anything that comes with a mouse. If you're using a mobile device you simply cannot jump to a category you love. This means you have to go for a work around, which is nowhere to be found if you're not a regular user.</p>
<h2>Who does this right?</h2>
<p class="imgpreview"><a href="http://www.webia.info/wp-content/uploads/2010/01/themeforest_logo_btn.jpg"><img src="http://www.webia.info/wp-content/uploads/2010/01/themeforest_logo_btn.jpg" alt="ThemeForest dot net screenshot" /></a></p>
<p>
If you think we're going to jump light years away to find another site that does this well, you're wrong. Remember that we talked about the logo, located just above the categories button? Well, next to the logo are two small arrows pointing out that something happens over there. If you click that small button you get a dropdown menu similar to the one you get when checking out categories. This menu is used to rapidly switch between Envato's marketplaces. My question is why did Envato implement click on their marketplace switch and hover on their categories menu?
</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/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>2. <a href="http://www.webia.info/articles/consistency-key-element-in-extraordinary-ux/" target="_new">Consistency. Key element in extraordinary UX</a></li>
<li>3. <a href="http://www.webia.info/articles/code/enhance-your-clients-list-with-jquery-goodness/" target="_new">Enhance your clients list page with jQuery goodness</a></li>
</ul>]]></content:encoded>
			<wfw:commentRss>http://www.webia.info/articles/usability/should-i-use-on-hover-behavior/feed/</wfw:commentRss>
		<slash:comments>3</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>
	</channel>
</rss>
