<?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>Elegant Code &#187; html</title>
	<atom:link href="http://elegantcode.com/category/html/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com</link>
	<description></description>
	<lastBuildDate>Tue, 15 May 2012 10:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>The Web is Not Platform Independent</title>
		<link>http://elegantcode.com/2010/08/22/the-web-is-not-platform-independent/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-web-is-not-platform-independent</link>
		<comments>http://elegantcode.com/2010/08/22/the-web-is-not-platform-independent/#comments</comments>
		<pubDate>Sun, 22 Aug 2010 20:16:32 +0000</pubDate>
		<dc:creator>John Sonmez</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/08/22/the-web-is-not-platform-independent/</guid>
		<description><![CDATA[There was a time when you wrote a web site and you targeted IE6. That time has long passed. When you really only had to target IE6, you could pretend the web was platform independent. The truth is now the web is neither, nor will ever be platform independent.&#160; It’s just an illusion based on [...]]]></description>
			<content:encoded><![CDATA[<p>There was a time when you wrote a web site and you targeted IE6.</p>  <p>That time has long passed.</p>  <p>When you really only had to target IE6, you could pretend the web was platform independent.</p>  <p>The truth is now the web is neither, nor will ever be platform independent.&#160; It’s just an illusion based on the simple notion that browsers basically just render HTML.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/08/pegi.jpg"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="pegi" border="0" alt="pegi" src="http://elegantcode.com/wp-content/uploads/2010/08/pegi_thumb.jpg" width="438" height="517" /></a></p>  <h2>How many platforms are there then?</h2>  <p>This is a surprisingly difficult question to answer.</p>  <p>Back before the web really took off there were basically 3 platforms to develop an app for: Windows; Unix/Linux; and Mac.</p>  <p>When we answer this question for the web, really we have to look at browsers as if they are the operating system.&#160; Since the same browser exists on multiple base OS’s but could be different, we have to count each combination of browser and OS as a potentially separate version.</p>  <p>Windows: IE6, IE7, IE8, IE9 (beta), Firefox, Chrome, Safari</p>  <p>OSX: IE, Firefox, Safari (more?)</p>  <p>Linux: Firefox, Chrome</p>  <p>Android: Webkit</p>  <p>iPad, iPhone: Safari</p>  <p>I don’t have nearly every combination listed, but this is what I would consider a good coverage for any kind of public facing website.</p>  <p>Oh, don’t forget to cross this again with localization and globalization, because you might have a localization problem that only happens in a certain language in a certain browser on a certain OS.</p>  <h2>Not just rendering level differences</h2>  <p>It is also very interesting to consider that a web developer now has to consider how their site will not just render, but be used on a mobile platform.&#160; </p>  <p>Consider how Google released an iPad version of Gmail.&#160; And although, you may not really care if your site works on an iPhone or an Android phone, you probably should start caring about how it works on tablets like the iPad, because that market is only growing. </p>  <p><strong>If you have a website that doesn’t work on someone’s iPad when they are shopping online, do you think they will get up, go turn on the computer, and go to your site to make the purchase or they will buy from a different site with a few touches?</strong></p>  <p>With a phone size resolution, the considerations are even more important.</p>  <h2>Tools help me make the web platform independent</h2>  <p>No tool exists right now that can handle the non-technical aspects of platform independence for your web application, but let us imagine for a second that a library like JQuery really made your javascript platform independent.</p>  <p>If we were to hold onto that shaky assumption, we would need to make sure that we never wrote javascript that wasn’t written through the JQuery API.&#160; (Which happens to be an extremely leaky abstraction over javascript, CSS, and the DOM.) We would still have to make sure our HTML and CSS tags were platform independent.</p>  <p>So even if we could get parts of our development to be mostly platform independent, we would still need to test on all of the major platforms, because we could not rely on the platform independence.</p>  <p>Now, don’t get me wrong here.&#160; I love JQuery.&#160; It makes the job of a web developer so much easier.&#160; But, there is an important distinction.&#160; <strong>APIs and libraries like JQuery make it easier to write platform independent web code, but they don’t make our code platform independent.</strong></p>  <h2>What does all this mean?</h2>  <p>We’ve gotten to the point where the most platform independent technology you can use is either Flash or Silverlight.</p>  <p>I’m not sure if this is the future of development, but it very well might be.</p>  <p>One important point to draw from this realization is that we shouldn’t necessarily choose to make our application a web application, because we need it to be platform independent.&#160; It seems like about 5 years ago, the web became the default choice, because it was better to have platform independence than a rich UI.</p>  <p>Hopefully, for the sake of web developers some of these paths die off or converge, or that standards compliance becomes so good that you could really write code for one browser and expect it to work on all the others.</p>  <h6>As always, you can subscribe to this <a href="http://feeds2.feedburner.com/ElegantCode">RSS feed</a> to follow my posts on elegant code.&#160; Feel free to check out my main personal blog at <a href="http://simpleprogrammer.com">http://simpleprogrammer.com</a>, which has a wider range of posts, updated 2-3 times a week.&#160; Also, you can follow me on twitter <a href="http://twitter.com/jsonmez">here</a>.</h6>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/08/22/the-web-is-not-platform-independent/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Your JavaScript goes WHERE?</title>
		<link>http://elegantcode.com/2010/03/30/your-javascript-goes-where/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=your-javascript-goes-where</link>
		<comments>http://elegantcode.com/2010/03/30/your-javascript-goes-where/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 03:35:37 +0000</pubDate>
		<dc:creator>Chris Brandsma</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/03/30/your-javascript-goes-where/</guid>
		<description><![CDATA[Let me start by saying that I was not trying to be controversial.  I was at Boise Code Camp giving a session about Asp.Net MVC, and I happened to mention that JavaScript was supposed to go at the bottom of your page.  Plus, I said this in a “of course you all know this already” [...]]]></description>
			<content:encoded><![CDATA[Let me start by saying that I was not trying to be controversial.  I was at Boise Code Camp giving a session about Asp.Net MVC, and I happened to mention that JavaScript was supposed to go at the bottom of your page.  Plus, I said this in a “of course you all know this already” type of voice, thinking this needed no further explanation.

Then the hands started raising.  Quickly, I might add.  I had to explain myself.  Yes, JavaScript goes at the bottom of your page.  Yes, I realize that we were all taught, back in the day, that JavaScript’s true home was in the &lt;head&gt; element.  In fact, <a href="http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery">many sample pages still show JavaScript at the top</a>.  But we probably learned that ten years ago, you have to think a few things have changed…except IE6 – that sucker is going to live forever!  Anyway, I’m not the type that like to stand up in a crowd and say “everything you, and everyone you know, is doing is wrong” (I’m not that smart).  And if I do, I want to come with some substantial proof.

To start, <a href="http://www.w3.org/TR/REC-html40/interact/scripts.html#h-18.2.1">where does the w3c say the SCRIPT element is supposed to go?</a>  If you read the document in the link, SCRIPT can live in either the HEAD or the BODY elements. So technically, both places are legal.  I am stating this so that no one come back and tells me I’m breaking any fundamental web rules.  If the w3c says it is ok, then it is ok darn it.
<h2>But why the bottom of the page? </h2>
That one is slightly harder to explain.  But here are the basics:  when a browser loads a document there are only so many thread for processing the document and download all the other crap that you put on the page <a href="http://theoatmeal.com/comics/design_hell">so it pops</a> (so, images and css, not to mention the bagillion font tags that Word likes to put in html).  There is also an unwritten rule that JavaScript should enhance the page after it is loaded.  So any time the browser spends parsing JavaScript is time it could be using to make the page look right.  Also, with some browsers, when the browser is loading JavaScript, ALL OTHER ACTIVITY STOPS.  Nothing else is downloaded, the browser is at a standstill until all the script is parsed – and <a href="http://ejohn.org/blog/javascript-performance-rundown/">you know how fast IE is at JavaScript.</a>

Lets be clear about this “rule”.  <a href="http://developer.yahoo.com/performance/rules.html#js_bottom">I did not make this up.</a>  But there are other ways around the performance penalty, you can also <a href="http://code.google.com/speed/page-speed/docs/payload.html#DeferLoadingJS">defer load</a> your JavaScript.  Also, putting all of the JavaScript into a single, external file is a great idea.  With a external file you get the added benefit of the JavaScript file being cached by the browser (Note: great for the user – pain for your tester.  Repeat after me, “CLEAR YOUR CACHE” often when testing).

OK, so let us review.

<a href="http://elegantcode.com/wp-content/uploads/2010/03/image17.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" src="http://elegantcode.com/wp-content/uploads/2010/03/image_thumb17.png" border="0" alt="image" width="823" height="594" /></a>
<h2>But how bad is this?</h2>
That is a fair question as well.  Truthfully, it depends.  I know that is my stock answer, but I’m talking about how much this will affect the user.  It could be nothing.  But if you have a lot of JavaScript on the page, it could be significant.   Potentially it could be as annoying as a blink tag.  Even worse it might be on par with ESPN and their auto-playing videos.   But, if we are talking about 10-20 lines of script, there could be no change at all in render time. I will say this, by moving the script to the bottom of the page I have taken pages that were not usable for 10 seconds, improved it to moments (the page had a LOT of JavaScript…and it was a very noble cause).
<h2>What else should I be doing that I’m not?</h2>
This one is easy.  Run all of your pages through <a href="http://developer.yahoo.com/yslow/">YSlow</a> and <a href="http://code.google.com/speed/page-speed/">PageSpeed</a> (you need FireFox and <a href="http://getfirebug.com/">Firebug</a> installed for this) and find out.  Also, you don’t have to be perfect as far as these tools are concerned.  Some of the rule are probably not practical either (the “You should be using a CDN for images” rule comes to mind).  But it is good to know where you can improve.  PageSpeed has a number of really nice tools as well.  It will return you properly sized images, and compressed CSS and JavaScript if you ask it.]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/03/30/your-javascript-goes-where/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Introducing oEmbed</title>
		<link>http://elegantcode.com/2010/03/05/introducing-oembed/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=introducing-oembed</link>
		<comments>http://elegantcode.com/2010/03/05/introducing-oembed/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 06:12:08 +0000</pubDate>
		<dc:creator>cory.isakson</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[WebServices]]></category>
		<category><![CDATA[oembed]]></category>

		<guid isPermaLink="false">http://elegantcode.com/?p=3325</guid>
		<description><![CDATA[Gadgets, widgets, flash, ActiveX, Silverlight, json, xml With all of the competing technologies for content embedding and resource sharing on the web it can be difficult to determine which options to use.  Have you ever wished that you could embed YouTube videos and Flickr photos into your site just by knowing the consumer friendly URLi’s [...]]]></description>
			<content:encoded><![CDATA[Gadgets, widgets, flash, ActiveX, Silverlight, json, xml

With all of the competing technologies for content embedding and resource sharing on the web it can be difficult to determine which options to use.  Have you ever wished that you could embed YouTube videos and Flickr photos into your site just by knowing the consumer friendly URLi’s to them?  That is exactly what <a href="http://oembed.com">oEmbed</a> provides.  I would like to introduce you to the basics of the specification.  I hope the simplicity encourages you to support it as a provider and as a consumer when embedding resources from other providers.  Many popular sites already support it!
<blockquote>oEmbed is a format for allowing an embedded representation of a URL on third party sites. The simple API allows a website to display embedded content (such as photos or videos) when a user posts a link to that resource, without having to parse the resource directly.</blockquote>
Lets take a look at each side of a provider and consumer scenario to illustrate how oEmbed provides and elegant solution for each.
<blockquote>Providers must specify one or more URL scheme and API endpoint pairs. The URL scheme describes which URLs provided by the service may have an embedded representation.</blockquote>
The publisher must determine what scheme(s) they support in very basic format.  Typically the scheme matches URLs that consumers would browse resources at normally.  The YouTube API, for example, supports URLs matching the scheme <a href="http://*.youtube.com/watch">http://*.youtube.com/watch</a>*

The API endpoint is simply an http URL at which consumers request oEmbed representations of the resources you provide.  Most of the current providers offer API endpoints with obvious URL’s like <a title="http://www.youtube.com/oembed" href="http://www.youtube.com/oembed">http://www.youtube.com/oembed</a> and <a title="http://www.flickr.com/services/oembed/" href="http://www.flickr.com/services/oembed/">http://www.flickr.com/services/oembed/</a>.

Once you have the endpoint you just need to host a service there that accepts 4 specific query parameters:

url : The urlencoded url that matches a supported provider defined scheme.
maxwidth : (optional) The maximum width you want for embedding the resource.
maxheight : (optional) The maximum height you want for embedding the resource.
format: (optional) xml or json are the possible values that determine the consumers desired response Content-Type.
<blockquote>Requests sent to the API endpoint must be HTTP GET requests, with all arguments sent as query parameters. All arguments must be urlencoded (as per RFC 1738).</blockquote>
oEmbed consumers make requests for the oEmbed representation of a resource by sending a basic GET request to an API endpoint with url query parameters and any optional parameters they choose.

A request to <a title="http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3D6lbDyXu7gUQ" href="http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3D6lbDyXu7gUQ">http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3D6lbDyXu7gUQ</a> results in a json response:
<pre>{
"provider_url": "http://www.youtube.com/",
"title": "Insert a YouTube Video With oEmbed Wordpress 2.9",
"html": "&lt;object width=\"480\" height=\"295\"&gt;
    &lt;param name=\"movie\" value=\"http://www.youtube.com/v/6lbDyXu7gUQ&amp;fs=1\"&gt;&lt;/param&gt;
    &lt;param name=\"allowFullScreen\" value=\"true\"&gt;&lt;/param&gt;
    &lt;param name=\"allowscriptaccess\" value=\"always\"&gt;&lt;/param&gt;
    &lt;embed src=\"http://www.youtube.com/v/6lbDyXu7gUQ&amp;fs=1\" type=\"application/x-shockwave-flash\"
        width=\"480\" height=\"295\" allowscriptaccess=\"always\" allowfullscreen=\"true\"&gt;&lt;/embed&gt;&lt;/object&gt;",
"author_name": "adriarichards", "height": 295, "width": 480, "version": "1.0",
"author_url": "http://www.youtube.com/user/adriarichards",
"provider_name": "YouTube",
"type": "video"
}</pre>
Note the html property.  It contains everything you need to embed the video.  If this installation of WordPress was running version 2.9 I could paste a YouTube URL here and it would automatically get embeded as described in the video <a href="http://www.youtube.com/watch?v=6lbDyXu7gUQ">Insert a YouTube Video With oEmbed Wordpress 2.9</a>

oEmbed supports 4 result types including video, photo, link and rich.  The rich type allows for just about any html to be returned and thus embedded.
<blockquote>Consumers may wish to load the HTML in an off-domain iframe to avoid XSS vulnerabilities.</blockquote>
To learn more and see a list of some current providers check it out at:

<a title="http://oembed.com/" href="http://oembed.com/">http://oembed.com/</a>

And for a few more implementations check out <a title="http://oohembed.com/" href="http://oohembed.com/">http://oohembed.com/</a>

I look forward to hearing how you end up using oEmbed!]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/03/05/introducing-oembed/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JetBrains Web IDE</title>
		<link>http://elegantcode.com/2010/01/29/jetbrains-web-ide/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=jetbrains-web-ide</link>
		<comments>http://elegantcode.com/2010/01/29/jetbrains-web-ide/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 21:03:26 +0000</pubDate>
		<dc:creator>Jan Van Ryswyck</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/01/29/jetbrains-web-ide/</guid>
		<description><![CDATA[As I already mentioned in a previous blog post, I’m kind of (re-)learning HTML and CSS. The best way for me to pick things up again is by getting my hands dirty and work myself through a simple example. So I decided to work on some sort of prototype of a web application without using [...]]]></description>
			<content:encoded><![CDATA[<p>As I already mentioned in a <a href="http://elegantcode.com/2010/01/26/css-basics-the-box-model/">previous blog post</a>, I’m kind of (re-)learning HTML and CSS. The best way for me to pick things up again is by getting my hands dirty and work myself through a simple example. So I decided to work on some sort of prototype of a web application without using any web framework like ASP.NET MVC, Fubu MVC, Ruby on Rails, etc. … Just plain old HTML and CSS, like the Internet gods intended. I also didn’t want to suck all the fun out of it either, so I decided to use <a href="http://www.jetbrains.com/webide/index.html">Web IDE</a> from <a href="http://www.jetbrains.com/index.html">JetBrains</a> as my IDE for churning out this prototype. </p>  <p>I must say that I was pleasantly surprised by some of the features that this IDE has to offer. The first and most obvious one is probably intellisense that just works as expected.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/01/image9.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/01/image_thumb9.png" width="553" height="385" /></a> </p>  <p>Also notice the on-the-fly code inspection (colored marker bar on the right) that should be familiar when you’re a Resharper addict like me. Web IDE provides W3C XHTML/CSS validation while working in the editor which is really useful. </p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/01/image10.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/01/image_thumb10.png" width="548" height="381" /></a> </p>  <p>Being the uncertain type, it was also nice to see all the familiar refactoring features from Resharper being available as well. Renaming a class or id is just a breeze. All the corresponding HTML or CSS files are consistently updated.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/01/image11.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/01/image_thumb11.png" width="546" height="382" /></a> </p>  <p>Navigation is there as well (CTRL-N and CTRL-SHIFT-N).</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/01/image12.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/01/image_thumb12.png" width="543" height="378" /></a> </p>  <p>This looks just like <a href="http://www.jetbrains.com/resharper/index.html">Resharper</a> for web developers, but there’s more. At first, I had all the HTML and CSS files including all the image file in the root folder of the project. I wanted to divide and conquer by putting the images and CSS files into their own separate folder. As I prepared myself to change all the references in the HTML files, Web IDE did that all for me when I dragged the files to their final destination. Now I didn’t had to go over all the HTML files and manually change the links. How cool is that!</p>  <p>Web IDE also provides source-control integration Subversion, Git, Perforce, etc … and that’s just the tip of the iceberg. While working on the prototype of the web application, I mostly focused on the layout and not so much on the behavior so I didn’t use much of the JavaScript capabilities. But I was told that it is comparable with the JavaScript features in <a href="http://www.jetbrains.com/ruby/index.html">RubyMine</a> as described by Peter in <a href="http://peter.worksontheweb.net/post/An-alternative-to-editing-JavaScript-in-Visual-Studio-RubyMine.aspx">this blog post</a>. This is something that I’m going to explore when I start learning more about JavaScript :-). </p>  <p>Although being the first version and still in beta, the IDE seems pretty stable and I couldn’t notice any performance hiccups so far (which <a href="http://davybrion.com/blog/2010/01/i-still-have-low-expectations-for-visual-studio-2010/">cannot be said for all IDE’s</a> these days). </p>  <p>I do hope that there will be some support for ASP.NET or other view engines like <a href="http://sparkviewengine.com/">Spark</a>, <a href="http://nvelocity.sourceforge.net/">NVelocity</a>, etc. … in future versions. In fact, I still silently wish that JetBrains would come up with an IDE for .NET. Being realistic about it, I don’t have high hopes for something like that coming out but it would totally rock if they decided to build one. Sweet dreams :-)</p>  <p>Bottom line, when you’re doing web development in Visual Studio, make sure to also check out Web IDE. It will probably help you to become more productive along the way.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/01/29/jetbrains-web-ide/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Playing with JQuery Validation library</title>
		<link>http://elegantcode.com/2009/09/27/playing-with-jquery-validation-library/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=playing-with-jquery-validation-library</link>
		<comments>http://elegantcode.com/2009/09/27/playing-with-jquery-validation-library/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 04:21:16 +0000</pubDate>
		<dc:creator>Chris Brandsma</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JQuery]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/09/27/playing-with-jquery-validation-library/</guid>
		<description><![CDATA[New job (2 weeks in), new responsibilities, new tools to play with.&#160; Amazingly (for me), one of the new tools is the JQuery Validation Library.&#160; My diving into this also coincides with ScottGu’s announcement that Microsoft is creating their own CDN for JQuery and JQuery Validation.&#160; Bad news is that this means I’m behind.&#160; That [...]]]></description>
			<content:encoded><![CDATA[<p>New job (2 weeks in), new responsibilities, new tools to play with.&#160; Amazingly (for me), one of the new tools is the <a href="http://docs.jquery.com/Plugins/Validation">JQuery Validation Library</a>.&#160; My diving into this also coincides with ScottGu’s announcement that Microsoft is creating their own <a href="http://weblogs.asp.net/scottgu/archive/2009/09/15/announcing-the-microsoft-ajax-cdn.aspx">CDN for JQuery and JQuery Validation</a>.&#160; </p>  <p>Bad news is that this means I’m behind.&#160; That sucks.&#160; I was using JQuery MONTHS before Microsoft officially started supporting it (at least 6 months – but I’m too lazy to look it up).&#160; Anyway, now you can use Microsoft’s bandwidth to get JQuery to your customer’s browser with this line:</p>  <p>&lt;script src=&quot;http://ajax.microsoft.com/ajax/jquery/jquery-1.3.2.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</p>  <p>And you can add the JQuery Validation library like this: </p>  <p>&lt;script src=&quot;http://ajax.microsoft.com/ajax/jquery.validate/1.5.5/jquery.validate.js&quot; type=”text/javascript”&gt;&lt;/script&gt;</p>  <p>Note: see those end tags, great annoyance of my life, but you have to have them, you can’t do &lt;script src=”http://…” /&gt;.&#160; That sucks, but I’m learning to live with it.</p>  <p>Anyway, back to validation.</p>  <p>The more I play with this library, the more I like it.&#160; It is very configurable, easily style-able, the documentation isn’t half bad, and the code is readable.</p>  <h2>Getting Started with JQuery Validation:</h2>  <p><strong>The JavaScript Way:</strong>&#160; OK, assuming you have JQuery and the JQuery Validation library included, lets start with a simple customer form:</p>  <p></p>  <div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">   <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">     <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">form</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;CustomerForm&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;firstNameEdit&quot;</span><span style="color: #0000ff">&gt;</span>First Name:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;firstNameEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;LastNameEdit&quot;</span><span style="color: #0000ff">&gt;</span>Last Name:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;LastNameEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;EmailEdit&quot;</span><span style="color: #0000ff">&gt;</span>Email:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12">  12:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;EmailEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13">  13:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14">  14:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum15">  15:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">button</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;submit&quot;</span><span style="color: #0000ff">&gt;</span>Submit<span style="color: #0000ff">&lt;/</span><span style="color: #800000">button</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum16">  16:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum17">  17:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">form</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF--></div>
</div>

<p>Nothing special there.&#160; Just a bunch of inputs and labels.&#160; If you hit the submit button, a postback is fired and the data is sent back to the server.</p>

<p>But, business requirements dictate that all fields are required.&#160; Simple enough, using JQuery the hookup looks like this:</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> $(<span style="color: #006080">&quot;#CustomerForm&quot;</span>).validate({</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span>     rules: {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span>       FirstNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>       LastNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>       EmailEdit: { required: <span style="color: #0000ff">true</span>, email:<span style="color: #0000ff">true</span> }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>     }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span> });</pre>
<!--CRLF--></div>
</div>

<p>OK, the first name, last name, and email will now be required.&#160; I also threw a little extra in there: email validation.&#160; If you submit the form like this will be added after any of the required fields:</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> &lt;label <span style="color: #0000ff">class</span>=<span style="color: #006080">&quot;error&quot;</span> <span style="color: #0000ff">for</span>=<span style="color: #006080">&quot;FirstName&quot;</span> generated=<span style="color: #006080">&quot;true&quot;</span>&gt;This field <span style="color: #0000ff">is</span> required.&lt;/label&gt;</pre>
<!--CRLF--></div>
</div>

<p>Key part there is the ‘error’ css class which is great for styling the messages.&#160; So you can use the ‘label.error’ in your css class.</p>

<h2>Another way</h2>

<p>You can also use css classes to setup which fields are required.&#160; It is a nice and simple way to hook everything up, but it is not as easily configurable (as we will see in a moment):</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">form</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;CustomerForm&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;FirstNameEdit&quot;</span><span style="color: #0000ff">&gt;</span>First Name:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;FirstNameEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot;</span> class=”required”<span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;LastNameEdit&quot;</span><span style="color: #0000ff">&gt;</span>Last Name:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;LastNameEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot; class=”required”</span> <span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;EmailEdit&quot;</span><span style="color: #0000ff">&gt;</span>Email:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12">  12:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;EmailEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot;</span> class=”required email”<span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13">  13:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14">  14:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum15">  15:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">button</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;submit&quot;</span><span style="color: #0000ff">&gt;</span>Submit<span style="color: #0000ff">&lt;/</span><span style="color: #800000">button</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum16">  16:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum17">  17:</span> <span style="color: #0000ff">&lt;/form</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF--></div>
</div>

<p>The the Javascript is actually much simpler:</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> $(<span style="color: #006080">&quot;CustomerForm&quot;</span>).validate();</pre>
<!--CRLF--></div>
</div>

<p>And you will get the same results.&#160; But, the rest of the samples will use the prior code setup.&#160; Also note: you can mix and match the css style with the JavaScript style.</p>

<h2>Moving the message</h2>

<p>Next problem you might encounter is you want to move the messages to another part of the screen.&#160; Remember, default behavior is the messages go next to the control.</p>

<p>To solve this we will add a div to the page:</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 31px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">div</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;RegisterErrors&quot;</span> <span style="color: #ff0000">style</span><span style="color: #0000ff">=&quot;display:none&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF--></div>
</div>

<p>I can setup the Validation library to use this by going back to the validate method and adding errorLabelContainer directive.</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> $(“#CustomerForm”).validate({</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> <strong>errorLabelContainer: $(<span style="color: #006080">&quot;#RegisterErrors&quot;</span>),</strong></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> rules: {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>         FirstNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>         LastNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>         EmailEdit: { required: <span style="color: #0000ff">true</span>, email: <span style="color: #0000ff">true</span> }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>     }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span> });</pre>
<!--CRLF--></div>
</div>

<p>Now this is great, but there is still a problem.&#160; Each of the messages will be “This field is required”.&#160; That doesn’t say which field is the problem.&#160; Lets add custom messages for each field.</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> </pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span>     $(<span style="color: #006080">&quot;#CustomerForm&quot;</span>).validate({</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span>     errorLabelContainer: $(<span style="color: #006080">&quot;#RegisterErrors&quot;</span>),</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>     rules: {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>             FirstNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>             LastNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>             EmailEdit: { required: <span style="color: #0000ff">true</span>, email: <span style="color: #0000ff">true</span> }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span>         },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span>         messages: {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span>             FirstNameEdit: <span style="color: #006080">&quot;First name is required&quot;</span>,</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span>             LastNameEdit: <span style="color: #006080">&quot;Last name is required&quot;</span>,</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12">  12:</span>             EmailEdit: <span style="color: #006080">&quot;Valid email address is required&quot;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13">  13:</span>         }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14">  14:</span>     });</pre>
<!--CRLF--></div>
</div>

<p></p>

<p>Which then gives better messages.</p>

<h2>For next time</h2>

<p>Ok, this is not all the JQuery Validation library can do, there is a lot more, but this is enough for now.&#160; Next post will show how to validate fields using web service results, and various callbacks that can be used to customize the library.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/09/27/playing-with-jquery-validation-library/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>FireFox+Firebug vs IE8 Developer Toolbar</title>
	<atom:link href="http://elegantcode.com/category/html/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com</link>
	<description></description>
	<lastBuildDate>Tue, 15 May 2012 10:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Elegant Code &#187; html</title>
	<atom:link href="http://elegantcode.com/category/html/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com</link>
	<description></description>
	<lastBuildDate>Tue, 15 May 2012 10:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>The Web is Not Platform Independent</title>
		<link>http://elegantcode.com/2010/08/22/the-web-is-not-platform-independent/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-web-is-not-platform-independent</link>
		<comments>http://elegantcode.com/2010/08/22/the-web-is-not-platform-independent/#comments</comments>
		<pubDate>Sun, 22 Aug 2010 20:16:32 +0000</pubDate>
		<dc:creator>John Sonmez</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/08/22/the-web-is-not-platform-independent/</guid>
		<description><![CDATA[There was a time when you wrote a web site and you targeted IE6. That time has long passed. When you really only had to target IE6, you could pretend the web was platform independent. The truth is now the web is neither, nor will ever be platform independent.&#160; It’s just an illusion based on [...]]]></description>
			<content:encoded><![CDATA[<p>There was a time when you wrote a web site and you targeted IE6.</p>  <p>That time has long passed.</p>  <p>When you really only had to target IE6, you could pretend the web was platform independent.</p>  <p>The truth is now the web is neither, nor will ever be platform independent.&#160; It’s just an illusion based on the simple notion that browsers basically just render HTML.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/08/pegi.jpg"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="pegi" border="0" alt="pegi" src="http://elegantcode.com/wp-content/uploads/2010/08/pegi_thumb.jpg" width="438" height="517" /></a></p>  <h2>How many platforms are there then?</h2>  <p>This is a surprisingly difficult question to answer.</p>  <p>Back before the web really took off there were basically 3 platforms to develop an app for: Windows; Unix/Linux; and Mac.</p>  <p>When we answer this question for the web, really we have to look at browsers as if they are the operating system.&#160; Since the same browser exists on multiple base OS’s but could be different, we have to count each combination of browser and OS as a potentially separate version.</p>  <p>Windows: IE6, IE7, IE8, IE9 (beta), Firefox, Chrome, Safari</p>  <p>OSX: IE, Firefox, Safari (more?)</p>  <p>Linux: Firefox, Chrome</p>  <p>Android: Webkit</p>  <p>iPad, iPhone: Safari</p>  <p>I don’t have nearly every combination listed, but this is what I would consider a good coverage for any kind of public facing website.</p>  <p>Oh, don’t forget to cross this again with localization and globalization, because you might have a localization problem that only happens in a certain language in a certain browser on a certain OS.</p>  <h2>Not just rendering level differences</h2>  <p>It is also very interesting to consider that a web developer now has to consider how their site will not just render, but be used on a mobile platform.&#160; </p>  <p>Consider how Google released an iPad version of Gmail.&#160; And although, you may not really care if your site works on an iPhone or an Android phone, you probably should start caring about how it works on tablets like the iPad, because that market is only growing. </p>  <p><strong>If you have a website that doesn’t work on someone’s iPad when they are shopping online, do you think they will get up, go turn on the computer, and go to your site to make the purchase or they will buy from a different site with a few touches?</strong></p>  <p>With a phone size resolution, the considerations are even more important.</p>  <h2>Tools help me make the web platform independent</h2>  <p>No tool exists right now that can handle the non-technical aspects of platform independence for your web application, but let us imagine for a second that a library like JQuery really made your javascript platform independent.</p>  <p>If we were to hold onto that shaky assumption, we would need to make sure that we never wrote javascript that wasn’t written through the JQuery API.&#160; (Which happens to be an extremely leaky abstraction over javascript, CSS, and the DOM.) We would still have to make sure our HTML and CSS tags were platform independent.</p>  <p>So even if we could get parts of our development to be mostly platform independent, we would still need to test on all of the major platforms, because we could not rely on the platform independence.</p>  <p>Now, don’t get me wrong here.&#160; I love JQuery.&#160; It makes the job of a web developer so much easier.&#160; But, there is an important distinction.&#160; <strong>APIs and libraries like JQuery make it easier to write platform independent web code, but they don’t make our code platform independent.</strong></p>  <h2>What does all this mean?</h2>  <p>We’ve gotten to the point where the most platform independent technology you can use is either Flash or Silverlight.</p>  <p>I’m not sure if this is the future of development, but it very well might be.</p>  <p>One important point to draw from this realization is that we shouldn’t necessarily choose to make our application a web application, because we need it to be platform independent.&#160; It seems like about 5 years ago, the web became the default choice, because it was better to have platform independence than a rich UI.</p>  <p>Hopefully, for the sake of web developers some of these paths die off or converge, or that standards compliance becomes so good that you could really write code for one browser and expect it to work on all the others.</p>  <h6>As always, you can subscribe to this <a href="http://feeds2.feedburner.com/ElegantCode">RSS feed</a> to follow my posts on elegant code.&#160; Feel free to check out my main personal blog at <a href="http://simpleprogrammer.com">http://simpleprogrammer.com</a>, which has a wider range of posts, updated 2-3 times a week.&#160; Also, you can follow me on twitter <a href="http://twitter.com/jsonmez">here</a>.</h6>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/08/22/the-web-is-not-platform-independent/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Your JavaScript goes WHERE?</title>
		<link>http://elegantcode.com/2010/03/30/your-javascript-goes-where/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=your-javascript-goes-where</link>
		<comments>http://elegantcode.com/2010/03/30/your-javascript-goes-where/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 03:35:37 +0000</pubDate>
		<dc:creator>Chris Brandsma</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/03/30/your-javascript-goes-where/</guid>
		<description><![CDATA[Let me start by saying that I was not trying to be controversial.  I was at Boise Code Camp giving a session about Asp.Net MVC, and I happened to mention that JavaScript was supposed to go at the bottom of your page.  Plus, I said this in a “of course you all know this already” [...]]]></description>
			<content:encoded><![CDATA[Let me start by saying that I was not trying to be controversial.  I was at Boise Code Camp giving a session about Asp.Net MVC, and I happened to mention that JavaScript was supposed to go at the bottom of your page.  Plus, I said this in a “of course you all know this already” type of voice, thinking this needed no further explanation.

Then the hands started raising.  Quickly, I might add.  I had to explain myself.  Yes, JavaScript goes at the bottom of your page.  Yes, I realize that we were all taught, back in the day, that JavaScript’s true home was in the &lt;head&gt; element.  In fact, <a href="http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery">many sample pages still show JavaScript at the top</a>.  But we probably learned that ten years ago, you have to think a few things have changed…except IE6 – that sucker is going to live forever!  Anyway, I’m not the type that like to stand up in a crowd and say “everything you, and everyone you know, is doing is wrong” (I’m not that smart).  And if I do, I want to come with some substantial proof.

To start, <a href="http://www.w3.org/TR/REC-html40/interact/scripts.html#h-18.2.1">where does the w3c say the SCRIPT element is supposed to go?</a>  If you read the document in the link, SCRIPT can live in either the HEAD or the BODY elements. So technically, both places are legal.  I am stating this so that no one come back and tells me I’m breaking any fundamental web rules.  If the w3c says it is ok, then it is ok darn it.
<h2>But why the bottom of the page? </h2>
That one is slightly harder to explain.  But here are the basics:  when a browser loads a document there are only so many thread for processing the document and download all the other crap that you put on the page <a href="http://theoatmeal.com/comics/design_hell">so it pops</a> (so, images and css, not to mention the bagillion font tags that Word likes to put in html).  There is also an unwritten rule that JavaScript should enhance the page after it is loaded.  So any time the browser spends parsing JavaScript is time it could be using to make the page look right.  Also, with some browsers, when the browser is loading JavaScript, ALL OTHER ACTIVITY STOPS.  Nothing else is downloaded, the browser is at a standstill until all the script is parsed – and <a href="http://ejohn.org/blog/javascript-performance-rundown/">you know how fast IE is at JavaScript.</a>

Lets be clear about this “rule”.  <a href="http://developer.yahoo.com/performance/rules.html#js_bottom">I did not make this up.</a>  But there are other ways around the performance penalty, you can also <a href="http://code.google.com/speed/page-speed/docs/payload.html#DeferLoadingJS">defer load</a> your JavaScript.  Also, putting all of the JavaScript into a single, external file is a great idea.  With a external file you get the added benefit of the JavaScript file being cached by the browser (Note: great for the user – pain for your tester.  Repeat after me, “CLEAR YOUR CACHE” often when testing).

OK, so let us review.

<a href="http://elegantcode.com/wp-content/uploads/2010/03/image17.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" src="http://elegantcode.com/wp-content/uploads/2010/03/image_thumb17.png" border="0" alt="image" width="823" height="594" /></a>
<h2>But how bad is this?</h2>
That is a fair question as well.  Truthfully, it depends.  I know that is my stock answer, but I’m talking about how much this will affect the user.  It could be nothing.  But if you have a lot of JavaScript on the page, it could be significant.   Potentially it could be as annoying as a blink tag.  Even worse it might be on par with ESPN and their auto-playing videos.   But, if we are talking about 10-20 lines of script, there could be no change at all in render time. I will say this, by moving the script to the bottom of the page I have taken pages that were not usable for 10 seconds, improved it to moments (the page had a LOT of JavaScript…and it was a very noble cause).
<h2>What else should I be doing that I’m not?</h2>
This one is easy.  Run all of your pages through <a href="http://developer.yahoo.com/yslow/">YSlow</a> and <a href="http://code.google.com/speed/page-speed/">PageSpeed</a> (you need FireFox and <a href="http://getfirebug.com/">Firebug</a> installed for this) and find out.  Also, you don’t have to be perfect as far as these tools are concerned.  Some of the rule are probably not practical either (the “You should be using a CDN for images” rule comes to mind).  But it is good to know where you can improve.  PageSpeed has a number of really nice tools as well.  It will return you properly sized images, and compressed CSS and JavaScript if you ask it.]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/03/30/your-javascript-goes-where/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Introducing oEmbed</title>
		<link>http://elegantcode.com/2010/03/05/introducing-oembed/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=introducing-oembed</link>
		<comments>http://elegantcode.com/2010/03/05/introducing-oembed/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 06:12:08 +0000</pubDate>
		<dc:creator>cory.isakson</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[WebServices]]></category>
		<category><![CDATA[oembed]]></category>

		<guid isPermaLink="false">http://elegantcode.com/?p=3325</guid>
		<description><![CDATA[Gadgets, widgets, flash, ActiveX, Silverlight, json, xml With all of the competing technologies for content embedding and resource sharing on the web it can be difficult to determine which options to use.  Have you ever wished that you could embed YouTube videos and Flickr photos into your site just by knowing the consumer friendly URLi’s [...]]]></description>
			<content:encoded><![CDATA[Gadgets, widgets, flash, ActiveX, Silverlight, json, xml

With all of the competing technologies for content embedding and resource sharing on the web it can be difficult to determine which options to use.  Have you ever wished that you could embed YouTube videos and Flickr photos into your site just by knowing the consumer friendly URLi’s to them?  That is exactly what <a href="http://oembed.com">oEmbed</a> provides.  I would like to introduce you to the basics of the specification.  I hope the simplicity encourages you to support it as a provider and as a consumer when embedding resources from other providers.  Many popular sites already support it!
<blockquote>oEmbed is a format for allowing an embedded representation of a URL on third party sites. The simple API allows a website to display embedded content (such as photos or videos) when a user posts a link to that resource, without having to parse the resource directly.</blockquote>
Lets take a look at each side of a provider and consumer scenario to illustrate how oEmbed provides and elegant solution for each.
<blockquote>Providers must specify one or more URL scheme and API endpoint pairs. The URL scheme describes which URLs provided by the service may have an embedded representation.</blockquote>
The publisher must determine what scheme(s) they support in very basic format.  Typically the scheme matches URLs that consumers would browse resources at normally.  The YouTube API, for example, supports URLs matching the scheme <a href="http://*.youtube.com/watch">http://*.youtube.com/watch</a>*

The API endpoint is simply an http URL at which consumers request oEmbed representations of the resources you provide.  Most of the current providers offer API endpoints with obvious URL’s like <a title="http://www.youtube.com/oembed" href="http://www.youtube.com/oembed">http://www.youtube.com/oembed</a> and <a title="http://www.flickr.com/services/oembed/" href="http://www.flickr.com/services/oembed/">http://www.flickr.com/services/oembed/</a>.

Once you have the endpoint you just need to host a service there that accepts 4 specific query parameters:

url : The urlencoded url that matches a supported provider defined scheme.
maxwidth : (optional) The maximum width you want for embedding the resource.
maxheight : (optional) The maximum height you want for embedding the resource.
format: (optional) xml or json are the possible values that determine the consumers desired response Content-Type.
<blockquote>Requests sent to the API endpoint must be HTTP GET requests, with all arguments sent as query parameters. All arguments must be urlencoded (as per RFC 1738).</blockquote>
oEmbed consumers make requests for the oEmbed representation of a resource by sending a basic GET request to an API endpoint with url query parameters and any optional parameters they choose.

A request to <a title="http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3D6lbDyXu7gUQ" href="http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3D6lbDyXu7gUQ">http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3D6lbDyXu7gUQ</a> results in a json response:
<pre>{
"provider_url": "http://www.youtube.com/",
"title": "Insert a YouTube Video With oEmbed Wordpress 2.9",
"html": "&lt;object width=\"480\" height=\"295\"&gt;
    &lt;param name=\"movie\" value=\"http://www.youtube.com/v/6lbDyXu7gUQ&amp;fs=1\"&gt;&lt;/param&gt;
    &lt;param name=\"allowFullScreen\" value=\"true\"&gt;&lt;/param&gt;
    &lt;param name=\"allowscriptaccess\" value=\"always\"&gt;&lt;/param&gt;
    &lt;embed src=\"http://www.youtube.com/v/6lbDyXu7gUQ&amp;fs=1\" type=\"application/x-shockwave-flash\"
        width=\"480\" height=\"295\" allowscriptaccess=\"always\" allowfullscreen=\"true\"&gt;&lt;/embed&gt;&lt;/object&gt;",
"author_name": "adriarichards", "height": 295, "width": 480, "version": "1.0",
"author_url": "http://www.youtube.com/user/adriarichards",
"provider_name": "YouTube",
"type": "video"
}</pre>
Note the html property.  It contains everything you need to embed the video.  If this installation of WordPress was running version 2.9 I could paste a YouTube URL here and it would automatically get embeded as described in the video <a href="http://www.youtube.com/watch?v=6lbDyXu7gUQ">Insert a YouTube Video With oEmbed Wordpress 2.9</a>

oEmbed supports 4 result types including video, photo, link and rich.  The rich type allows for just about any html to be returned and thus embedded.
<blockquote>Consumers may wish to load the HTML in an off-domain iframe to avoid XSS vulnerabilities.</blockquote>
To learn more and see a list of some current providers check it out at:

<a title="http://oembed.com/" href="http://oembed.com/">http://oembed.com/</a>

And for a few more implementations check out <a title="http://oohembed.com/" href="http://oohembed.com/">http://oohembed.com/</a>

I look forward to hearing how you end up using oEmbed!]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/03/05/introducing-oembed/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JetBrains Web IDE</title>
		<link>http://elegantcode.com/2010/01/29/jetbrains-web-ide/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=jetbrains-web-ide</link>
		<comments>http://elegantcode.com/2010/01/29/jetbrains-web-ide/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 21:03:26 +0000</pubDate>
		<dc:creator>Jan Van Ryswyck</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/01/29/jetbrains-web-ide/</guid>
		<description><![CDATA[As I already mentioned in a previous blog post, I’m kind of (re-)learning HTML and CSS. The best way for me to pick things up again is by getting my hands dirty and work myself through a simple example. So I decided to work on some sort of prototype of a web application without using [...]]]></description>
			<content:encoded><![CDATA[<p>As I already mentioned in a <a href="http://elegantcode.com/2010/01/26/css-basics-the-box-model/">previous blog post</a>, I’m kind of (re-)learning HTML and CSS. The best way for me to pick things up again is by getting my hands dirty and work myself through a simple example. So I decided to work on some sort of prototype of a web application without using any web framework like ASP.NET MVC, Fubu MVC, Ruby on Rails, etc. … Just plain old HTML and CSS, like the Internet gods intended. I also didn’t want to suck all the fun out of it either, so I decided to use <a href="http://www.jetbrains.com/webide/index.html">Web IDE</a> from <a href="http://www.jetbrains.com/index.html">JetBrains</a> as my IDE for churning out this prototype. </p>  <p>I must say that I was pleasantly surprised by some of the features that this IDE has to offer. The first and most obvious one is probably intellisense that just works as expected.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/01/image9.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/01/image_thumb9.png" width="553" height="385" /></a> </p>  <p>Also notice the on-the-fly code inspection (colored marker bar on the right) that should be familiar when you’re a Resharper addict like me. Web IDE provides W3C XHTML/CSS validation while working in the editor which is really useful. </p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/01/image10.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/01/image_thumb10.png" width="548" height="381" /></a> </p>  <p>Being the uncertain type, it was also nice to see all the familiar refactoring features from Resharper being available as well. Renaming a class or id is just a breeze. All the corresponding HTML or CSS files are consistently updated.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/01/image11.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/01/image_thumb11.png" width="546" height="382" /></a> </p>  <p>Navigation is there as well (CTRL-N and CTRL-SHIFT-N).</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/01/image12.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/01/image_thumb12.png" width="543" height="378" /></a> </p>  <p>This looks just like <a href="http://www.jetbrains.com/resharper/index.html">Resharper</a> for web developers, but there’s more. At first, I had all the HTML and CSS files including all the image file in the root folder of the project. I wanted to divide and conquer by putting the images and CSS files into their own separate folder. As I prepared myself to change all the references in the HTML files, Web IDE did that all for me when I dragged the files to their final destination. Now I didn’t had to go over all the HTML files and manually change the links. How cool is that!</p>  <p>Web IDE also provides source-control integration Subversion, Git, Perforce, etc … and that’s just the tip of the iceberg. While working on the prototype of the web application, I mostly focused on the layout and not so much on the behavior so I didn’t use much of the JavaScript capabilities. But I was told that it is comparable with the JavaScript features in <a href="http://www.jetbrains.com/ruby/index.html">RubyMine</a> as described by Peter in <a href="http://peter.worksontheweb.net/post/An-alternative-to-editing-JavaScript-in-Visual-Studio-RubyMine.aspx">this blog post</a>. This is something that I’m going to explore when I start learning more about JavaScript :-). </p>  <p>Although being the first version and still in beta, the IDE seems pretty stable and I couldn’t notice any performance hiccups so far (which <a href="http://davybrion.com/blog/2010/01/i-still-have-low-expectations-for-visual-studio-2010/">cannot be said for all IDE’s</a> these days). </p>  <p>I do hope that there will be some support for ASP.NET or other view engines like <a href="http://sparkviewengine.com/">Spark</a>, <a href="http://nvelocity.sourceforge.net/">NVelocity</a>, etc. … in future versions. In fact, I still silently wish that JetBrains would come up with an IDE for .NET. Being realistic about it, I don’t have high hopes for something like that coming out but it would totally rock if they decided to build one. Sweet dreams :-)</p>  <p>Bottom line, when you’re doing web development in Visual Studio, make sure to also check out Web IDE. It will probably help you to become more productive along the way.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/01/29/jetbrains-web-ide/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Playing with JQuery Validation library</title>
		<link>http://elegantcode.com/2009/09/27/playing-with-jquery-validation-library/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=playing-with-jquery-validation-library</link>
		<comments>http://elegantcode.com/2009/09/27/playing-with-jquery-validation-library/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 04:21:16 +0000</pubDate>
		<dc:creator>Chris Brandsma</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JQuery]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/09/27/playing-with-jquery-validation-library/</guid>
		<description><![CDATA[New job (2 weeks in), new responsibilities, new tools to play with.&#160; Amazingly (for me), one of the new tools is the JQuery Validation Library.&#160; My diving into this also coincides with ScottGu’s announcement that Microsoft is creating their own CDN for JQuery and JQuery Validation.&#160; Bad news is that this means I’m behind.&#160; That [...]]]></description>
			<content:encoded><![CDATA[<p>New job (2 weeks in), new responsibilities, new tools to play with.&#160; Amazingly (for me), one of the new tools is the <a href="http://docs.jquery.com/Plugins/Validation">JQuery Validation Library</a>.&#160; My diving into this also coincides with ScottGu’s announcement that Microsoft is creating their own <a href="http://weblogs.asp.net/scottgu/archive/2009/09/15/announcing-the-microsoft-ajax-cdn.aspx">CDN for JQuery and JQuery Validation</a>.&#160; </p>  <p>Bad news is that this means I’m behind.&#160; That sucks.&#160; I was using JQuery MONTHS before Microsoft officially started supporting it (at least 6 months – but I’m too lazy to look it up).&#160; Anyway, now you can use Microsoft’s bandwidth to get JQuery to your customer’s browser with this line:</p>  <p>&lt;script src=&quot;http://ajax.microsoft.com/ajax/jquery/jquery-1.3.2.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</p>  <p>And you can add the JQuery Validation library like this: </p>  <p>&lt;script src=&quot;http://ajax.microsoft.com/ajax/jquery.validate/1.5.5/jquery.validate.js&quot; type=”text/javascript”&gt;&lt;/script&gt;</p>  <p>Note: see those end tags, great annoyance of my life, but you have to have them, you can’t do &lt;script src=”http://…” /&gt;.&#160; That sucks, but I’m learning to live with it.</p>  <p>Anyway, back to validation.</p>  <p>The more I play with this library, the more I like it.&#160; It is very configurable, easily style-able, the documentation isn’t half bad, and the code is readable.</p>  <h2>Getting Started with JQuery Validation:</h2>  <p><strong>The JavaScript Way:</strong>&#160; OK, assuming you have JQuery and the JQuery Validation library included, lets start with a simple customer form:</p>  <p></p>  <div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">   <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">     <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">form</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;CustomerForm&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;firstNameEdit&quot;</span><span style="color: #0000ff">&gt;</span>First Name:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;firstNameEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;LastNameEdit&quot;</span><span style="color: #0000ff">&gt;</span>Last Name:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;LastNameEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;EmailEdit&quot;</span><span style="color: #0000ff">&gt;</span>Email:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12">  12:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;EmailEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13">  13:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14">  14:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum15">  15:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">button</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;submit&quot;</span><span style="color: #0000ff">&gt;</span>Submit<span style="color: #0000ff">&lt;/</span><span style="color: #800000">button</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum16">  16:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum17">  17:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">form</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF--></div>
</div>

<p>Nothing special there.&#160; Just a bunch of inputs and labels.&#160; If you hit the submit button, a postback is fired and the data is sent back to the server.</p>

<p>But, business requirements dictate that all fields are required.&#160; Simple enough, using JQuery the hookup looks like this:</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> $(<span style="color: #006080">&quot;#CustomerForm&quot;</span>).validate({</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span>     rules: {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span>       FirstNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>       LastNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>       EmailEdit: { required: <span style="color: #0000ff">true</span>, email:<span style="color: #0000ff">true</span> }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>     }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span> });</pre>
<!--CRLF--></div>
</div>

<p>OK, the first name, last name, and email will now be required.&#160; I also threw a little extra in there: email validation.&#160; If you submit the form like this will be added after any of the required fields:</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> &lt;label <span style="color: #0000ff">class</span>=<span style="color: #006080">&quot;error&quot;</span> <span style="color: #0000ff">for</span>=<span style="color: #006080">&quot;FirstName&quot;</span> generated=<span style="color: #006080">&quot;true&quot;</span>&gt;This field <span style="color: #0000ff">is</span> required.&lt;/label&gt;</pre>
<!--CRLF--></div>
</div>

<p>Key part there is the ‘error’ css class which is great for styling the messages.&#160; So you can use the ‘label.error’ in your css class.</p>

<h2>Another way</h2>

<p>You can also use css classes to setup which fields are required.&#160; It is a nice and simple way to hook everything up, but it is not as easily configurable (as we will see in a moment):</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">form</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;CustomerForm&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;FirstNameEdit&quot;</span><span style="color: #0000ff">&gt;</span>First Name:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;FirstNameEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot;</span> class=”required”<span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;LastNameEdit&quot;</span><span style="color: #0000ff">&gt;</span>Last Name:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;LastNameEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot; class=”required”</span> <span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;EmailEdit&quot;</span><span style="color: #0000ff">&gt;</span>Email:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12">  12:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;EmailEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot;</span> class=”required email”<span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13">  13:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14">  14:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum15">  15:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">button</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;submit&quot;</span><span style="color: #0000ff">&gt;</span>Submit<span style="color: #0000ff">&lt;/</span><span style="color: #800000">button</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum16">  16:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum17">  17:</span> <span style="color: #0000ff">&lt;/form</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF--></div>
</div>

<p>The the Javascript is actually much simpler:</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> $(<span style="color: #006080">&quot;CustomerForm&quot;</span>).validate();</pre>
<!--CRLF--></div>
</div>

<p>And you will get the same results.&#160; But, the rest of the samples will use the prior code setup.&#160; Also note: you can mix and match the css style with the JavaScript style.</p>

<h2>Moving the message</h2>

<p>Next problem you might encounter is you want to move the messages to another part of the screen.&#160; Remember, default behavior is the messages go next to the control.</p>

<p>To solve this we will add a div to the page:</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 31px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">div</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;RegisterErrors&quot;</span> <span style="color: #ff0000">style</span><span style="color: #0000ff">=&quot;display:none&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF--></div>
</div>

<p>I can setup the Validation library to use this by going back to the validate method and adding errorLabelContainer directive.</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> $(“#CustomerForm”).validate({</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> <strong>errorLabelContainer: $(<span style="color: #006080">&quot;#RegisterErrors&quot;</span>),</strong></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> rules: {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>         FirstNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>         LastNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>         EmailEdit: { required: <span style="color: #0000ff">true</span>, email: <span style="color: #0000ff">true</span> }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>     }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span> });</pre>
<!--CRLF--></div>
</div>

<p>Now this is great, but there is still a problem.&#160; Each of the messages will be “This field is required”.&#160; That doesn’t say which field is the problem.&#160; Lets add custom messages for each field.</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> </pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span>     $(<span style="color: #006080">&quot;#CustomerForm&quot;</span>).validate({</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span>     errorLabelContainer: $(<span style="color: #006080">&quot;#RegisterErrors&quot;</span>),</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>     rules: {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>             FirstNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>             LastNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>             EmailEdit: { required: <span style="color: #0000ff">true</span>, email: <span style="color: #0000ff">true</span> }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span>         },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span>         messages: {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span>             FirstNameEdit: <span style="color: #006080">&quot;First name is required&quot;</span>,</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span>             LastNameEdit: <span style="color: #006080">&quot;Last name is required&quot;</span>,</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12">  12:</span>             EmailEdit: <span style="color: #006080">&quot;Valid email address is required&quot;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13">  13:</span>         }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14">  14:</span>     });</pre>
<!--CRLF--></div>
</div>

<p></p>

<p>Which then gives better messages.</p>

<h2>For next time</h2>

<p>Ok, this is not all the JQuery Validation library can do, there is a lot more, but this is enough for now.&#160; Next post will show how to validate fields using web service results, and various callbacks that can be used to customize the library.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/09/27/playing-with-jquery-validation-library/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>FireFox+Firebug vs IE8 Developer Toolbar</title>
		<link>http://elegantcode.com/2010/08/22/the-web-is-not-platform-independent/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-web-is-not-platform-independent</link>
		<comments>http://elegantcode.com/2010/08/22/the-web-is-not-platform-independent/#comments</comments>
		<pubDate>Sun, 22 Aug 2010 20:16:32 +0000</pubDate>
		<dc:creator>John Sonmez</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/08/22/the-web-is-not-platform-independent/</guid>
		<description><![CDATA[There was a time when you wrote a web site and you targeted IE6. That time has long passed. When you really only had to target IE6, you could pretend the web was platform independent. The truth is now the web is neither, nor will ever be platform independent.&#160; It’s just an illusion based on [...]]]></description>
			<content:encoded><![CDATA[<p>There was a time when you wrote a web site and you targeted IE6.</p>  <p>That time has long passed.</p>  <p>When you really only had to target IE6, you could pretend the web was platform independent.</p>  <p>The truth is now the web is neither, nor will ever be platform independent.&#160; It’s just an illusion based on the simple notion that browsers basically just render HTML.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/08/pegi.jpg"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="pegi" border="0" alt="pegi" src="http://elegantcode.com/wp-content/uploads/2010/08/pegi_thumb.jpg" width="438" height="517" /></a></p>  <h2>How many platforms are there then?</h2>  <p>This is a surprisingly difficult question to answer.</p>  <p>Back before the web really took off there were basically 3 platforms to develop an app for: Windows; Unix/Linux; and Mac.</p>  <p>When we answer this question for the web, really we have to look at browsers as if they are the operating system.&#160; Since the same browser exists on multiple base OS’s but could be different, we have to count each combination of browser and OS as a potentially separate version.</p>  <p>Windows: IE6, IE7, IE8, IE9 (beta), Firefox, Chrome, Safari</p>  <p>OSX: IE, Firefox, Safari (more?)</p>  <p>Linux: Firefox, Chrome</p>  <p>Android: Webkit</p>  <p>iPad, iPhone: Safari</p>  <p>I don’t have nearly every combination listed, but this is what I would consider a good coverage for any kind of public facing website.</p>  <p>Oh, don’t forget to cross this again with localization and globalization, because you might have a localization problem that only happens in a certain language in a certain browser on a certain OS.</p>  <h2>Not just rendering level differences</h2>  <p>It is also very interesting to consider that a web developer now has to consider how their site will not just render, but be used on a mobile platform.&#160; </p>  <p>Consider how Google released an iPad version of Gmail.&#160; And although, you may not really care if your site works on an iPhone or an Android phone, you probably should start caring about how it works on tablets like the iPad, because that market is only growing. </p>  <p><strong>If you have a website that doesn’t work on someone’s iPad when they are shopping online, do you think they will get up, go turn on the computer, and go to your site to make the purchase or they will buy from a different site with a few touches?</strong></p>  <p>With a phone size resolution, the considerations are even more important.</p>  <h2>Tools help me make the web platform independent</h2>  <p>No tool exists right now that can handle the non-technical aspects of platform independence for your web application, but let us imagine for a second that a library like JQuery really made your javascript platform independent.</p>  <p>If we were to hold onto that shaky assumption, we would need to make sure that we never wrote javascript that wasn’t written through the JQuery API.&#160; (Which happens to be an extremely leaky abstraction over javascript, CSS, and the DOM.) We would still have to make sure our HTML and CSS tags were platform independent.</p>  <p>So even if we could get parts of our development to be mostly platform independent, we would still need to test on all of the major platforms, because we could not rely on the platform independence.</p>  <p>Now, don’t get me wrong here.&#160; I love JQuery.&#160; It makes the job of a web developer so much easier.&#160; But, there is an important distinction.&#160; <strong>APIs and libraries like JQuery make it easier to write platform independent web code, but they don’t make our code platform independent.</strong></p>  <h2>What does all this mean?</h2>  <p>We’ve gotten to the point where the most platform independent technology you can use is either Flash or Silverlight.</p>  <p>I’m not sure if this is the future of development, but it very well might be.</p>  <p>One important point to draw from this realization is that we shouldn’t necessarily choose to make our application a web application, because we need it to be platform independent.&#160; It seems like about 5 years ago, the web became the default choice, because it was better to have platform independence than a rich UI.</p>  <p>Hopefully, for the sake of web developers some of these paths die off or converge, or that standards compliance becomes so good that you could really write code for one browser and expect it to work on all the others.</p>  <h6>As always, you can subscribe to this <a href="http://feeds2.feedburner.com/ElegantCode">RSS feed</a> to follow my posts on elegant code.&#160; Feel free to check out my main personal blog at <a href="http://simpleprogrammer.com">http://simpleprogrammer.com</a>, which has a wider range of posts, updated 2-3 times a week.&#160; Also, you can follow me on twitter <a href="http://twitter.com/jsonmez">here</a>.</h6>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/08/22/the-web-is-not-platform-independent/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Elegant Code &#187; html</title>
	<atom:link href="http://elegantcode.com/category/html/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com</link>
	<description></description>
	<lastBuildDate>Tue, 15 May 2012 10:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>The Web is Not Platform Independent</title>
		<link>http://elegantcode.com/2010/08/22/the-web-is-not-platform-independent/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-web-is-not-platform-independent</link>
		<comments>http://elegantcode.com/2010/08/22/the-web-is-not-platform-independent/#comments</comments>
		<pubDate>Sun, 22 Aug 2010 20:16:32 +0000</pubDate>
		<dc:creator>John Sonmez</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/08/22/the-web-is-not-platform-independent/</guid>
		<description><![CDATA[There was a time when you wrote a web site and you targeted IE6. That time has long passed. When you really only had to target IE6, you could pretend the web was platform independent. The truth is now the web is neither, nor will ever be platform independent.&#160; It’s just an illusion based on [...]]]></description>
			<content:encoded><![CDATA[<p>There was a time when you wrote a web site and you targeted IE6.</p>  <p>That time has long passed.</p>  <p>When you really only had to target IE6, you could pretend the web was platform independent.</p>  <p>The truth is now the web is neither, nor will ever be platform independent.&#160; It’s just an illusion based on the simple notion that browsers basically just render HTML.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/08/pegi.jpg"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="pegi" border="0" alt="pegi" src="http://elegantcode.com/wp-content/uploads/2010/08/pegi_thumb.jpg" width="438" height="517" /></a></p>  <h2>How many platforms are there then?</h2>  <p>This is a surprisingly difficult question to answer.</p>  <p>Back before the web really took off there were basically 3 platforms to develop an app for: Windows; Unix/Linux; and Mac.</p>  <p>When we answer this question for the web, really we have to look at browsers as if they are the operating system.&#160; Since the same browser exists on multiple base OS’s but could be different, we have to count each combination of browser and OS as a potentially separate version.</p>  <p>Windows: IE6, IE7, IE8, IE9 (beta), Firefox, Chrome, Safari</p>  <p>OSX: IE, Firefox, Safari (more?)</p>  <p>Linux: Firefox, Chrome</p>  <p>Android: Webkit</p>  <p>iPad, iPhone: Safari</p>  <p>I don’t have nearly every combination listed, but this is what I would consider a good coverage for any kind of public facing website.</p>  <p>Oh, don’t forget to cross this again with localization and globalization, because you might have a localization problem that only happens in a certain language in a certain browser on a certain OS.</p>  <h2>Not just rendering level differences</h2>  <p>It is also very interesting to consider that a web developer now has to consider how their site will not just render, but be used on a mobile platform.&#160; </p>  <p>Consider how Google released an iPad version of Gmail.&#160; And although, you may not really care if your site works on an iPhone or an Android phone, you probably should start caring about how it works on tablets like the iPad, because that market is only growing. </p>  <p><strong>If you have a website that doesn’t work on someone’s iPad when they are shopping online, do you think they will get up, go turn on the computer, and go to your site to make the purchase or they will buy from a different site with a few touches?</strong></p>  <p>With a phone size resolution, the considerations are even more important.</p>  <h2>Tools help me make the web platform independent</h2>  <p>No tool exists right now that can handle the non-technical aspects of platform independence for your web application, but let us imagine for a second that a library like JQuery really made your javascript platform independent.</p>  <p>If we were to hold onto that shaky assumption, we would need to make sure that we never wrote javascript that wasn’t written through the JQuery API.&#160; (Which happens to be an extremely leaky abstraction over javascript, CSS, and the DOM.) We would still have to make sure our HTML and CSS tags were platform independent.</p>  <p>So even if we could get parts of our development to be mostly platform independent, we would still need to test on all of the major platforms, because we could not rely on the platform independence.</p>  <p>Now, don’t get me wrong here.&#160; I love JQuery.&#160; It makes the job of a web developer so much easier.&#160; But, there is an important distinction.&#160; <strong>APIs and libraries like JQuery make it easier to write platform independent web code, but they don’t make our code platform independent.</strong></p>  <h2>What does all this mean?</h2>  <p>We’ve gotten to the point where the most platform independent technology you can use is either Flash or Silverlight.</p>  <p>I’m not sure if this is the future of development, but it very well might be.</p>  <p>One important point to draw from this realization is that we shouldn’t necessarily choose to make our application a web application, because we need it to be platform independent.&#160; It seems like about 5 years ago, the web became the default choice, because it was better to have platform independence than a rich UI.</p>  <p>Hopefully, for the sake of web developers some of these paths die off or converge, or that standards compliance becomes so good that you could really write code for one browser and expect it to work on all the others.</p>  <h6>As always, you can subscribe to this <a href="http://feeds2.feedburner.com/ElegantCode">RSS feed</a> to follow my posts on elegant code.&#160; Feel free to check out my main personal blog at <a href="http://simpleprogrammer.com">http://simpleprogrammer.com</a>, which has a wider range of posts, updated 2-3 times a week.&#160; Also, you can follow me on twitter <a href="http://twitter.com/jsonmez">here</a>.</h6>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/08/22/the-web-is-not-platform-independent/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Your JavaScript goes WHERE?</title>
		<link>http://elegantcode.com/2010/03/30/your-javascript-goes-where/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=your-javascript-goes-where</link>
		<comments>http://elegantcode.com/2010/03/30/your-javascript-goes-where/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 03:35:37 +0000</pubDate>
		<dc:creator>Chris Brandsma</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/03/30/your-javascript-goes-where/</guid>
		<description><![CDATA[Let me start by saying that I was not trying to be controversial.  I was at Boise Code Camp giving a session about Asp.Net MVC, and I happened to mention that JavaScript was supposed to go at the bottom of your page.  Plus, I said this in a “of course you all know this already” [...]]]></description>
			<content:encoded><![CDATA[Let me start by saying that I was not trying to be controversial.  I was at Boise Code Camp giving a session about Asp.Net MVC, and I happened to mention that JavaScript was supposed to go at the bottom of your page.  Plus, I said this in a “of course you all know this already” type of voice, thinking this needed no further explanation.

Then the hands started raising.  Quickly, I might add.  I had to explain myself.  Yes, JavaScript goes at the bottom of your page.  Yes, I realize that we were all taught, back in the day, that JavaScript’s true home was in the &lt;head&gt; element.  In fact, <a href="http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery">many sample pages still show JavaScript at the top</a>.  But we probably learned that ten years ago, you have to think a few things have changed…except IE6 – that sucker is going to live forever!  Anyway, I’m not the type that like to stand up in a crowd and say “everything you, and everyone you know, is doing is wrong” (I’m not that smart).  And if I do, I want to come with some substantial proof.

To start, <a href="http://www.w3.org/TR/REC-html40/interact/scripts.html#h-18.2.1">where does the w3c say the SCRIPT element is supposed to go?</a>  If you read the document in the link, SCRIPT can live in either the HEAD or the BODY elements. So technically, both places are legal.  I am stating this so that no one come back and tells me I’m breaking any fundamental web rules.  If the w3c says it is ok, then it is ok darn it.
<h2>But why the bottom of the page? </h2>
That one is slightly harder to explain.  But here are the basics:  when a browser loads a document there are only so many thread for processing the document and download all the other crap that you put on the page <a href="http://theoatmeal.com/comics/design_hell">so it pops</a> (so, images and css, not to mention the bagillion font tags that Word likes to put in html).  There is also an unwritten rule that JavaScript should enhance the page after it is loaded.  So any time the browser spends parsing JavaScript is time it could be using to make the page look right.  Also, with some browsers, when the browser is loading JavaScript, ALL OTHER ACTIVITY STOPS.  Nothing else is downloaded, the browser is at a standstill until all the script is parsed – and <a href="http://ejohn.org/blog/javascript-performance-rundown/">you know how fast IE is at JavaScript.</a>

Lets be clear about this “rule”.  <a href="http://developer.yahoo.com/performance/rules.html#js_bottom">I did not make this up.</a>  But there are other ways around the performance penalty, you can also <a href="http://code.google.com/speed/page-speed/docs/payload.html#DeferLoadingJS">defer load</a> your JavaScript.  Also, putting all of the JavaScript into a single, external file is a great idea.  With a external file you get the added benefit of the JavaScript file being cached by the browser (Note: great for the user – pain for your tester.  Repeat after me, “CLEAR YOUR CACHE” often when testing).

OK, so let us review.

<a href="http://elegantcode.com/wp-content/uploads/2010/03/image17.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" src="http://elegantcode.com/wp-content/uploads/2010/03/image_thumb17.png" border="0" alt="image" width="823" height="594" /></a>
<h2>But how bad is this?</h2>
That is a fair question as well.  Truthfully, it depends.  I know that is my stock answer, but I’m talking about how much this will affect the user.  It could be nothing.  But if you have a lot of JavaScript on the page, it could be significant.   Potentially it could be as annoying as a blink tag.  Even worse it might be on par with ESPN and their auto-playing videos.   But, if we are talking about 10-20 lines of script, there could be no change at all in render time. I will say this, by moving the script to the bottom of the page I have taken pages that were not usable for 10 seconds, improved it to moments (the page had a LOT of JavaScript…and it was a very noble cause).
<h2>What else should I be doing that I’m not?</h2>
This one is easy.  Run all of your pages through <a href="http://developer.yahoo.com/yslow/">YSlow</a> and <a href="http://code.google.com/speed/page-speed/">PageSpeed</a> (you need FireFox and <a href="http://getfirebug.com/">Firebug</a> installed for this) and find out.  Also, you don’t have to be perfect as far as these tools are concerned.  Some of the rule are probably not practical either (the “You should be using a CDN for images” rule comes to mind).  But it is good to know where you can improve.  PageSpeed has a number of really nice tools as well.  It will return you properly sized images, and compressed CSS and JavaScript if you ask it.]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/03/30/your-javascript-goes-where/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Introducing oEmbed</title>
		<link>http://elegantcode.com/2010/03/05/introducing-oembed/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=introducing-oembed</link>
		<comments>http://elegantcode.com/2010/03/05/introducing-oembed/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 06:12:08 +0000</pubDate>
		<dc:creator>cory.isakson</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[WebServices]]></category>
		<category><![CDATA[oembed]]></category>

		<guid isPermaLink="false">http://elegantcode.com/?p=3325</guid>
		<description><![CDATA[Gadgets, widgets, flash, ActiveX, Silverlight, json, xml With all of the competing technologies for content embedding and resource sharing on the web it can be difficult to determine which options to use.  Have you ever wished that you could embed YouTube videos and Flickr photos into your site just by knowing the consumer friendly URLi’s [...]]]></description>
			<content:encoded><![CDATA[Gadgets, widgets, flash, ActiveX, Silverlight, json, xml

With all of the competing technologies for content embedding and resource sharing on the web it can be difficult to determine which options to use.  Have you ever wished that you could embed YouTube videos and Flickr photos into your site just by knowing the consumer friendly URLi’s to them?  That is exactly what <a href="http://oembed.com">oEmbed</a> provides.  I would like to introduce you to the basics of the specification.  I hope the simplicity encourages you to support it as a provider and as a consumer when embedding resources from other providers.  Many popular sites already support it!
<blockquote>oEmbed is a format for allowing an embedded representation of a URL on third party sites. The simple API allows a website to display embedded content (such as photos or videos) when a user posts a link to that resource, without having to parse the resource directly.</blockquote>
Lets take a look at each side of a provider and consumer scenario to illustrate how oEmbed provides and elegant solution for each.
<blockquote>Providers must specify one or more URL scheme and API endpoint pairs. The URL scheme describes which URLs provided by the service may have an embedded representation.</blockquote>
The publisher must determine what scheme(s) they support in very basic format.  Typically the scheme matches URLs that consumers would browse resources at normally.  The YouTube API, for example, supports URLs matching the scheme <a href="http://*.youtube.com/watch">http://*.youtube.com/watch</a>*

The API endpoint is simply an http URL at which consumers request oEmbed representations of the resources you provide.  Most of the current providers offer API endpoints with obvious URL’s like <a title="http://www.youtube.com/oembed" href="http://www.youtube.com/oembed">http://www.youtube.com/oembed</a> and <a title="http://www.flickr.com/services/oembed/" href="http://www.flickr.com/services/oembed/">http://www.flickr.com/services/oembed/</a>.

Once you have the endpoint you just need to host a service there that accepts 4 specific query parameters:

url : The urlencoded url that matches a supported provider defined scheme.
maxwidth : (optional) The maximum width you want for embedding the resource.
maxheight : (optional) The maximum height you want for embedding the resource.
format: (optional) xml or json are the possible values that determine the consumers desired response Content-Type.
<blockquote>Requests sent to the API endpoint must be HTTP GET requests, with all arguments sent as query parameters. All arguments must be urlencoded (as per RFC 1738).</blockquote>
oEmbed consumers make requests for the oEmbed representation of a resource by sending a basic GET request to an API endpoint with url query parameters and any optional parameters they choose.

A request to <a title="http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3D6lbDyXu7gUQ" href="http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3D6lbDyXu7gUQ">http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3D6lbDyXu7gUQ</a> results in a json response:
<pre>{
"provider_url": "http://www.youtube.com/",
"title": "Insert a YouTube Video With oEmbed Wordpress 2.9",
"html": "&lt;object width=\"480\" height=\"295\"&gt;
    &lt;param name=\"movie\" value=\"http://www.youtube.com/v/6lbDyXu7gUQ&amp;fs=1\"&gt;&lt;/param&gt;
    &lt;param name=\"allowFullScreen\" value=\"true\"&gt;&lt;/param&gt;
    &lt;param name=\"allowscriptaccess\" value=\"always\"&gt;&lt;/param&gt;
    &lt;embed src=\"http://www.youtube.com/v/6lbDyXu7gUQ&amp;fs=1\" type=\"application/x-shockwave-flash\"
        width=\"480\" height=\"295\" allowscriptaccess=\"always\" allowfullscreen=\"true\"&gt;&lt;/embed&gt;&lt;/object&gt;",
"author_name": "adriarichards", "height": 295, "width": 480, "version": "1.0",
"author_url": "http://www.youtube.com/user/adriarichards",
"provider_name": "YouTube",
"type": "video"
}</pre>
Note the html property.  It contains everything you need to embed the video.  If this installation of WordPress was running version 2.9 I could paste a YouTube URL here and it would automatically get embeded as described in the video <a href="http://www.youtube.com/watch?v=6lbDyXu7gUQ">Insert a YouTube Video With oEmbed Wordpress 2.9</a>

oEmbed supports 4 result types including video, photo, link and rich.  The rich type allows for just about any html to be returned and thus embedded.
<blockquote>Consumers may wish to load the HTML in an off-domain iframe to avoid XSS vulnerabilities.</blockquote>
To learn more and see a list of some current providers check it out at:

<a title="http://oembed.com/" href="http://oembed.com/">http://oembed.com/</a>

And for a few more implementations check out <a title="http://oohembed.com/" href="http://oohembed.com/">http://oohembed.com/</a>

I look forward to hearing how you end up using oEmbed!]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/03/05/introducing-oembed/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JetBrains Web IDE</title>
		<link>http://elegantcode.com/2010/01/29/jetbrains-web-ide/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=jetbrains-web-ide</link>
		<comments>http://elegantcode.com/2010/01/29/jetbrains-web-ide/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 21:03:26 +0000</pubDate>
		<dc:creator>Jan Van Ryswyck</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/01/29/jetbrains-web-ide/</guid>
		<description><![CDATA[As I already mentioned in a previous blog post, I’m kind of (re-)learning HTML and CSS. The best way for me to pick things up again is by getting my hands dirty and work myself through a simple example. So I decided to work on some sort of prototype of a web application without using [...]]]></description>
			<content:encoded><![CDATA[<p>As I already mentioned in a <a href="http://elegantcode.com/2010/01/26/css-basics-the-box-model/">previous blog post</a>, I’m kind of (re-)learning HTML and CSS. The best way for me to pick things up again is by getting my hands dirty and work myself through a simple example. So I decided to work on some sort of prototype of a web application without using any web framework like ASP.NET MVC, Fubu MVC, Ruby on Rails, etc. … Just plain old HTML and CSS, like the Internet gods intended. I also didn’t want to suck all the fun out of it either, so I decided to use <a href="http://www.jetbrains.com/webide/index.html">Web IDE</a> from <a href="http://www.jetbrains.com/index.html">JetBrains</a> as my IDE for churning out this prototype. </p>  <p>I must say that I was pleasantly surprised by some of the features that this IDE has to offer. The first and most obvious one is probably intellisense that just works as expected.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/01/image9.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/01/image_thumb9.png" width="553" height="385" /></a> </p>  <p>Also notice the on-the-fly code inspection (colored marker bar on the right) that should be familiar when you’re a Resharper addict like me. Web IDE provides W3C XHTML/CSS validation while working in the editor which is really useful. </p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/01/image10.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/01/image_thumb10.png" width="548" height="381" /></a> </p>  <p>Being the uncertain type, it was also nice to see all the familiar refactoring features from Resharper being available as well. Renaming a class or id is just a breeze. All the corresponding HTML or CSS files are consistently updated.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/01/image11.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/01/image_thumb11.png" width="546" height="382" /></a> </p>  <p>Navigation is there as well (CTRL-N and CTRL-SHIFT-N).</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/01/image12.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/01/image_thumb12.png" width="543" height="378" /></a> </p>  <p>This looks just like <a href="http://www.jetbrains.com/resharper/index.html">Resharper</a> for web developers, but there’s more. At first, I had all the HTML and CSS files including all the image file in the root folder of the project. I wanted to divide and conquer by putting the images and CSS files into their own separate folder. As I prepared myself to change all the references in the HTML files, Web IDE did that all for me when I dragged the files to their final destination. Now I didn’t had to go over all the HTML files and manually change the links. How cool is that!</p>  <p>Web IDE also provides source-control integration Subversion, Git, Perforce, etc … and that’s just the tip of the iceberg. While working on the prototype of the web application, I mostly focused on the layout and not so much on the behavior so I didn’t use much of the JavaScript capabilities. But I was told that it is comparable with the JavaScript features in <a href="http://www.jetbrains.com/ruby/index.html">RubyMine</a> as described by Peter in <a href="http://peter.worksontheweb.net/post/An-alternative-to-editing-JavaScript-in-Visual-Studio-RubyMine.aspx">this blog post</a>. This is something that I’m going to explore when I start learning more about JavaScript :-). </p>  <p>Although being the first version and still in beta, the IDE seems pretty stable and I couldn’t notice any performance hiccups so far (which <a href="http://davybrion.com/blog/2010/01/i-still-have-low-expectations-for-visual-studio-2010/">cannot be said for all IDE’s</a> these days). </p>  <p>I do hope that there will be some support for ASP.NET or other view engines like <a href="http://sparkviewengine.com/">Spark</a>, <a href="http://nvelocity.sourceforge.net/">NVelocity</a>, etc. … in future versions. In fact, I still silently wish that JetBrains would come up with an IDE for .NET. Being realistic about it, I don’t have high hopes for something like that coming out but it would totally rock if they decided to build one. Sweet dreams :-)</p>  <p>Bottom line, when you’re doing web development in Visual Studio, make sure to also check out Web IDE. It will probably help you to become more productive along the way.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/01/29/jetbrains-web-ide/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Playing with JQuery Validation library</title>
		<link>http://elegantcode.com/2009/09/27/playing-with-jquery-validation-library/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=playing-with-jquery-validation-library</link>
		<comments>http://elegantcode.com/2009/09/27/playing-with-jquery-validation-library/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 04:21:16 +0000</pubDate>
		<dc:creator>Chris Brandsma</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JQuery]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/09/27/playing-with-jquery-validation-library/</guid>
		<description><![CDATA[New job (2 weeks in), new responsibilities, new tools to play with.&#160; Amazingly (for me), one of the new tools is the JQuery Validation Library.&#160; My diving into this also coincides with ScottGu’s announcement that Microsoft is creating their own CDN for JQuery and JQuery Validation.&#160; Bad news is that this means I’m behind.&#160; That [...]]]></description>
			<content:encoded><![CDATA[<p>New job (2 weeks in), new responsibilities, new tools to play with.&#160; Amazingly (for me), one of the new tools is the <a href="http://docs.jquery.com/Plugins/Validation">JQuery Validation Library</a>.&#160; My diving into this also coincides with ScottGu’s announcement that Microsoft is creating their own <a href="http://weblogs.asp.net/scottgu/archive/2009/09/15/announcing-the-microsoft-ajax-cdn.aspx">CDN for JQuery and JQuery Validation</a>.&#160; </p>  <p>Bad news is that this means I’m behind.&#160; That sucks.&#160; I was using JQuery MONTHS before Microsoft officially started supporting it (at least 6 months – but I’m too lazy to look it up).&#160; Anyway, now you can use Microsoft’s bandwidth to get JQuery to your customer’s browser with this line:</p>  <p>&lt;script src=&quot;http://ajax.microsoft.com/ajax/jquery/jquery-1.3.2.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</p>  <p>And you can add the JQuery Validation library like this: </p>  <p>&lt;script src=&quot;http://ajax.microsoft.com/ajax/jquery.validate/1.5.5/jquery.validate.js&quot; type=”text/javascript”&gt;&lt;/script&gt;</p>  <p>Note: see those end tags, great annoyance of my life, but you have to have them, you can’t do &lt;script src=”http://…” /&gt;.&#160; That sucks, but I’m learning to live with it.</p>  <p>Anyway, back to validation.</p>  <p>The more I play with this library, the more I like it.&#160; It is very configurable, easily style-able, the documentation isn’t half bad, and the code is readable.</p>  <h2>Getting Started with JQuery Validation:</h2>  <p><strong>The JavaScript Way:</strong>&#160; OK, assuming you have JQuery and the JQuery Validation library included, lets start with a simple customer form:</p>  <p></p>  <div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">   <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">     <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">form</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;CustomerForm&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;firstNameEdit&quot;</span><span style="color: #0000ff">&gt;</span>First Name:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;firstNameEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;LastNameEdit&quot;</span><span style="color: #0000ff">&gt;</span>Last Name:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;LastNameEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;EmailEdit&quot;</span><span style="color: #0000ff">&gt;</span>Email:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12">  12:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;EmailEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13">  13:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14">  14:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum15">  15:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">button</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;submit&quot;</span><span style="color: #0000ff">&gt;</span>Submit<span style="color: #0000ff">&lt;/</span><span style="color: #800000">button</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum16">  16:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum17">  17:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">form</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF--></div>
</div>

<p>Nothing special there.&#160; Just a bunch of inputs and labels.&#160; If you hit the submit button, a postback is fired and the data is sent back to the server.</p>

<p>But, business requirements dictate that all fields are required.&#160; Simple enough, using JQuery the hookup looks like this:</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> $(<span style="color: #006080">&quot;#CustomerForm&quot;</span>).validate({</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span>     rules: {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span>       FirstNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>       LastNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>       EmailEdit: { required: <span style="color: #0000ff">true</span>, email:<span style="color: #0000ff">true</span> }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>     }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span> });</pre>
<!--CRLF--></div>
</div>

<p>OK, the first name, last name, and email will now be required.&#160; I also threw a little extra in there: email validation.&#160; If you submit the form like this will be added after any of the required fields:</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> &lt;label <span style="color: #0000ff">class</span>=<span style="color: #006080">&quot;error&quot;</span> <span style="color: #0000ff">for</span>=<span style="color: #006080">&quot;FirstName&quot;</span> generated=<span style="color: #006080">&quot;true&quot;</span>&gt;This field <span style="color: #0000ff">is</span> required.&lt;/label&gt;</pre>
<!--CRLF--></div>
</div>

<p>Key part there is the ‘error’ css class which is great for styling the messages.&#160; So you can use the ‘label.error’ in your css class.</p>

<h2>Another way</h2>

<p>You can also use css classes to setup which fields are required.&#160; It is a nice and simple way to hook everything up, but it is not as easily configurable (as we will see in a moment):</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">form</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;CustomerForm&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;FirstNameEdit&quot;</span><span style="color: #0000ff">&gt;</span>First Name:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;FirstNameEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot;</span> class=”required”<span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;LastNameEdit&quot;</span><span style="color: #0000ff">&gt;</span>Last Name:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;LastNameEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot; class=”required”</span> <span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;EmailEdit&quot;</span><span style="color: #0000ff">&gt;</span>Email:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12">  12:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;EmailEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot;</span> class=”required email”<span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13">  13:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14">  14:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum15">  15:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">button</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;submit&quot;</span><span style="color: #0000ff">&gt;</span>Submit<span style="color: #0000ff">&lt;/</span><span style="color: #800000">button</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum16">  16:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum17">  17:</span> <span style="color: #0000ff">&lt;/form</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF--></div>
</div>

<p>The the Javascript is actually much simpler:</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> $(<span style="color: #006080">&quot;CustomerForm&quot;</span>).validate();</pre>
<!--CRLF--></div>
</div>

<p>And you will get the same results.&#160; But, the rest of the samples will use the prior code setup.&#160; Also note: you can mix and match the css style with the JavaScript style.</p>

<h2>Moving the message</h2>

<p>Next problem you might encounter is you want to move the messages to another part of the screen.&#160; Remember, default behavior is the messages go next to the control.</p>

<p>To solve this we will add a div to the page:</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 31px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">div</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;RegisterErrors&quot;</span> <span style="color: #ff0000">style</span><span style="color: #0000ff">=&quot;display:none&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF--></div>
</div>

<p>I can setup the Validation library to use this by going back to the validate method and adding errorLabelContainer directive.</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> $(“#CustomerForm”).validate({</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> <strong>errorLabelContainer: $(<span style="color: #006080">&quot;#RegisterErrors&quot;</span>),</strong></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> rules: {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>         FirstNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>         LastNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>         EmailEdit: { required: <span style="color: #0000ff">true</span>, email: <span style="color: #0000ff">true</span> }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>     }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span> });</pre>
<!--CRLF--></div>
</div>

<p>Now this is great, but there is still a problem.&#160; Each of the messages will be “This field is required”.&#160; That doesn’t say which field is the problem.&#160; Lets add custom messages for each field.</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> </pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span>     $(<span style="color: #006080">&quot;#CustomerForm&quot;</span>).validate({</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span>     errorLabelContainer: $(<span style="color: #006080">&quot;#RegisterErrors&quot;</span>),</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>     rules: {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>             FirstNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>             LastNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>             EmailEdit: { required: <span style="color: #0000ff">true</span>, email: <span style="color: #0000ff">true</span> }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span>         },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span>         messages: {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span>             FirstNameEdit: <span style="color: #006080">&quot;First name is required&quot;</span>,</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span>             LastNameEdit: <span style="color: #006080">&quot;Last name is required&quot;</span>,</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12">  12:</span>             EmailEdit: <span style="color: #006080">&quot;Valid email address is required&quot;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13">  13:</span>         }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14">  14:</span>     });</pre>
<!--CRLF--></div>
</div>

<p></p>

<p>Which then gives better messages.</p>

<h2>For next time</h2>

<p>Ok, this is not all the JQuery Validation library can do, there is a lot more, but this is enough for now.&#160; Next post will show how to validate fields using web service results, and various callbacks that can be used to customize the library.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/09/27/playing-with-jquery-validation-library/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>FireFox+Firebug vs IE8 Developer Toolbar</title>
		<link>http://elegantcode.com/2010/03/30/your-javascript-goes-where/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=your-javascript-goes-where</link>
		<comments>http://elegantcode.com/2010/03/30/your-javascript-goes-where/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 03:35:37 +0000</pubDate>
		<dc:creator>Chris Brandsma</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/03/30/your-javascript-goes-where/</guid>
		<description><![CDATA[Let me start by saying that I was not trying to be controversial.  I was at Boise Code Camp giving a session about Asp.Net MVC, and I happened to mention that JavaScript was supposed to go at the bottom of your page.  Plus, I said this in a “of course you all know this already” [...]]]></description>
			<content:encoded><![CDATA[Let me start by saying that I was not trying to be controversial.  I was at Boise Code Camp giving a session about Asp.Net MVC, and I happened to mention that JavaScript was supposed to go at the bottom of your page.  Plus, I said this in a “of course you all know this already” type of voice, thinking this needed no further explanation.

Then the hands started raising.  Quickly, I might add.  I had to explain myself.  Yes, JavaScript goes at the bottom of your page.  Yes, I realize that we were all taught, back in the day, that JavaScript’s true home was in the &lt;head&gt; element.  In fact, <a href="http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery">many sample pages still show JavaScript at the top</a>.  But we probably learned that ten years ago, you have to think a few things have changed…except IE6 – that sucker is going to live forever!  Anyway, I’m not the type that like to stand up in a crowd and say “everything you, and everyone you know, is doing is wrong” (I’m not that smart).  And if I do, I want to come with some substantial proof.

To start, <a href="http://www.w3.org/TR/REC-html40/interact/scripts.html#h-18.2.1">where does the w3c say the SCRIPT element is supposed to go?</a>  If you read the document in the link, SCRIPT can live in either the HEAD or the BODY elements. So technically, both places are legal.  I am stating this so that no one come back and tells me I’m breaking any fundamental web rules.  If the w3c says it is ok, then it is ok darn it.
<h2>But why the bottom of the page? </h2>
That one is slightly harder to explain.  But here are the basics:  when a browser loads a document there are only so many thread for processing the document and download all the other crap that you put on the page <a href="http://theoatmeal.com/comics/design_hell">so it pops</a> (so, images and css, not to mention the bagillion font tags that Word likes to put in html).  There is also an unwritten rule that JavaScript should enhance the page after it is loaded.  So any time the browser spends parsing JavaScript is time it could be using to make the page look right.  Also, with some browsers, when the browser is loading JavaScript, ALL OTHER ACTIVITY STOPS.  Nothing else is downloaded, the browser is at a standstill until all the script is parsed – and <a href="http://ejohn.org/blog/javascript-performance-rundown/">you know how fast IE is at JavaScript.</a>

Lets be clear about this “rule”.  <a href="http://developer.yahoo.com/performance/rules.html#js_bottom">I did not make this up.</a>  But there are other ways around the performance penalty, you can also <a href="http://code.google.com/speed/page-speed/docs/payload.html#DeferLoadingJS">defer load</a> your JavaScript.  Also, putting all of the JavaScript into a single, external file is a great idea.  With a external file you get the added benefit of the JavaScript file being cached by the browser (Note: great for the user – pain for your tester.  Repeat after me, “CLEAR YOUR CACHE” often when testing).

OK, so let us review.

<a href="http://elegantcode.com/wp-content/uploads/2010/03/image17.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" src="http://elegantcode.com/wp-content/uploads/2010/03/image_thumb17.png" border="0" alt="image" width="823" height="594" /></a>
<h2>But how bad is this?</h2>
That is a fair question as well.  Truthfully, it depends.  I know that is my stock answer, but I’m talking about how much this will affect the user.  It could be nothing.  But if you have a lot of JavaScript on the page, it could be significant.   Potentially it could be as annoying as a blink tag.  Even worse it might be on par with ESPN and their auto-playing videos.   But, if we are talking about 10-20 lines of script, there could be no change at all in render time. I will say this, by moving the script to the bottom of the page I have taken pages that were not usable for 10 seconds, improved it to moments (the page had a LOT of JavaScript…and it was a very noble cause).
<h2>What else should I be doing that I’m not?</h2>
This one is easy.  Run all of your pages through <a href="http://developer.yahoo.com/yslow/">YSlow</a> and <a href="http://code.google.com/speed/page-speed/">PageSpeed</a> (you need FireFox and <a href="http://getfirebug.com/">Firebug</a> installed for this) and find out.  Also, you don’t have to be perfect as far as these tools are concerned.  Some of the rule are probably not practical either (the “You should be using a CDN for images” rule comes to mind).  But it is good to know where you can improve.  PageSpeed has a number of really nice tools as well.  It will return you properly sized images, and compressed CSS and JavaScript if you ask it.]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/03/30/your-javascript-goes-where/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Elegant Code &#187; html</title>
	<atom:link href="http://elegantcode.com/category/html/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com</link>
	<description></description>
	<lastBuildDate>Tue, 15 May 2012 10:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>The Web is Not Platform Independent</title>
		<link>http://elegantcode.com/2010/08/22/the-web-is-not-platform-independent/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-web-is-not-platform-independent</link>
		<comments>http://elegantcode.com/2010/08/22/the-web-is-not-platform-independent/#comments</comments>
		<pubDate>Sun, 22 Aug 2010 20:16:32 +0000</pubDate>
		<dc:creator>John Sonmez</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/08/22/the-web-is-not-platform-independent/</guid>
		<description><![CDATA[There was a time when you wrote a web site and you targeted IE6. That time has long passed. When you really only had to target IE6, you could pretend the web was platform independent. The truth is now the web is neither, nor will ever be platform independent.&#160; It’s just an illusion based on [...]]]></description>
			<content:encoded><![CDATA[<p>There was a time when you wrote a web site and you targeted IE6.</p>  <p>That time has long passed.</p>  <p>When you really only had to target IE6, you could pretend the web was platform independent.</p>  <p>The truth is now the web is neither, nor will ever be platform independent.&#160; It’s just an illusion based on the simple notion that browsers basically just render HTML.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/08/pegi.jpg"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="pegi" border="0" alt="pegi" src="http://elegantcode.com/wp-content/uploads/2010/08/pegi_thumb.jpg" width="438" height="517" /></a></p>  <h2>How many platforms are there then?</h2>  <p>This is a surprisingly difficult question to answer.</p>  <p>Back before the web really took off there were basically 3 platforms to develop an app for: Windows; Unix/Linux; and Mac.</p>  <p>When we answer this question for the web, really we have to look at browsers as if they are the operating system.&#160; Since the same browser exists on multiple base OS’s but could be different, we have to count each combination of browser and OS as a potentially separate version.</p>  <p>Windows: IE6, IE7, IE8, IE9 (beta), Firefox, Chrome, Safari</p>  <p>OSX: IE, Firefox, Safari (more?)</p>  <p>Linux: Firefox, Chrome</p>  <p>Android: Webkit</p>  <p>iPad, iPhone: Safari</p>  <p>I don’t have nearly every combination listed, but this is what I would consider a good coverage for any kind of public facing website.</p>  <p>Oh, don’t forget to cross this again with localization and globalization, because you might have a localization problem that only happens in a certain language in a certain browser on a certain OS.</p>  <h2>Not just rendering level differences</h2>  <p>It is also very interesting to consider that a web developer now has to consider how their site will not just render, but be used on a mobile platform.&#160; </p>  <p>Consider how Google released an iPad version of Gmail.&#160; And although, you may not really care if your site works on an iPhone or an Android phone, you probably should start caring about how it works on tablets like the iPad, because that market is only growing. </p>  <p><strong>If you have a website that doesn’t work on someone’s iPad when they are shopping online, do you think they will get up, go turn on the computer, and go to your site to make the purchase or they will buy from a different site with a few touches?</strong></p>  <p>With a phone size resolution, the considerations are even more important.</p>  <h2>Tools help me make the web platform independent</h2>  <p>No tool exists right now that can handle the non-technical aspects of platform independence for your web application, but let us imagine for a second that a library like JQuery really made your javascript platform independent.</p>  <p>If we were to hold onto that shaky assumption, we would need to make sure that we never wrote javascript that wasn’t written through the JQuery API.&#160; (Which happens to be an extremely leaky abstraction over javascript, CSS, and the DOM.) We would still have to make sure our HTML and CSS tags were platform independent.</p>  <p>So even if we could get parts of our development to be mostly platform independent, we would still need to test on all of the major platforms, because we could not rely on the platform independence.</p>  <p>Now, don’t get me wrong here.&#160; I love JQuery.&#160; It makes the job of a web developer so much easier.&#160; But, there is an important distinction.&#160; <strong>APIs and libraries like JQuery make it easier to write platform independent web code, but they don’t make our code platform independent.</strong></p>  <h2>What does all this mean?</h2>  <p>We’ve gotten to the point where the most platform independent technology you can use is either Flash or Silverlight.</p>  <p>I’m not sure if this is the future of development, but it very well might be.</p>  <p>One important point to draw from this realization is that we shouldn’t necessarily choose to make our application a web application, because we need it to be platform independent.&#160; It seems like about 5 years ago, the web became the default choice, because it was better to have platform independence than a rich UI.</p>  <p>Hopefully, for the sake of web developers some of these paths die off or converge, or that standards compliance becomes so good that you could really write code for one browser and expect it to work on all the others.</p>  <h6>As always, you can subscribe to this <a href="http://feeds2.feedburner.com/ElegantCode">RSS feed</a> to follow my posts on elegant code.&#160; Feel free to check out my main personal blog at <a href="http://simpleprogrammer.com">http://simpleprogrammer.com</a>, which has a wider range of posts, updated 2-3 times a week.&#160; Also, you can follow me on twitter <a href="http://twitter.com/jsonmez">here</a>.</h6>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/08/22/the-web-is-not-platform-independent/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Your JavaScript goes WHERE?</title>
		<link>http://elegantcode.com/2010/03/30/your-javascript-goes-where/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=your-javascript-goes-where</link>
		<comments>http://elegantcode.com/2010/03/30/your-javascript-goes-where/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 03:35:37 +0000</pubDate>
		<dc:creator>Chris Brandsma</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/03/30/your-javascript-goes-where/</guid>
		<description><![CDATA[Let me start by saying that I was not trying to be controversial.  I was at Boise Code Camp giving a session about Asp.Net MVC, and I happened to mention that JavaScript was supposed to go at the bottom of your page.  Plus, I said this in a “of course you all know this already” [...]]]></description>
			<content:encoded><![CDATA[Let me start by saying that I was not trying to be controversial.  I was at Boise Code Camp giving a session about Asp.Net MVC, and I happened to mention that JavaScript was supposed to go at the bottom of your page.  Plus, I said this in a “of course you all know this already” type of voice, thinking this needed no further explanation.

Then the hands started raising.  Quickly, I might add.  I had to explain myself.  Yes, JavaScript goes at the bottom of your page.  Yes, I realize that we were all taught, back in the day, that JavaScript’s true home was in the &lt;head&gt; element.  In fact, <a href="http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery">many sample pages still show JavaScript at the top</a>.  But we probably learned that ten years ago, you have to think a few things have changed…except IE6 – that sucker is going to live forever!  Anyway, I’m not the type that like to stand up in a crowd and say “everything you, and everyone you know, is doing is wrong” (I’m not that smart).  And if I do, I want to come with some substantial proof.

To start, <a href="http://www.w3.org/TR/REC-html40/interact/scripts.html#h-18.2.1">where does the w3c say the SCRIPT element is supposed to go?</a>  If you read the document in the link, SCRIPT can live in either the HEAD or the BODY elements. So technically, both places are legal.  I am stating this so that no one come back and tells me I’m breaking any fundamental web rules.  If the w3c says it is ok, then it is ok darn it.
<h2>But why the bottom of the page? </h2>
That one is slightly harder to explain.  But here are the basics:  when a browser loads a document there are only so many thread for processing the document and download all the other crap that you put on the page <a href="http://theoatmeal.com/comics/design_hell">so it pops</a> (so, images and css, not to mention the bagillion font tags that Word likes to put in html).  There is also an unwritten rule that JavaScript should enhance the page after it is loaded.  So any time the browser spends parsing JavaScript is time it could be using to make the page look right.  Also, with some browsers, when the browser is loading JavaScript, ALL OTHER ACTIVITY STOPS.  Nothing else is downloaded, the browser is at a standstill until all the script is parsed – and <a href="http://ejohn.org/blog/javascript-performance-rundown/">you know how fast IE is at JavaScript.</a>

Lets be clear about this “rule”.  <a href="http://developer.yahoo.com/performance/rules.html#js_bottom">I did not make this up.</a>  But there are other ways around the performance penalty, you can also <a href="http://code.google.com/speed/page-speed/docs/payload.html#DeferLoadingJS">defer load</a> your JavaScript.  Also, putting all of the JavaScript into a single, external file is a great idea.  With a external file you get the added benefit of the JavaScript file being cached by the browser (Note: great for the user – pain for your tester.  Repeat after me, “CLEAR YOUR CACHE” often when testing).

OK, so let us review.

<a href="http://elegantcode.com/wp-content/uploads/2010/03/image17.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" src="http://elegantcode.com/wp-content/uploads/2010/03/image_thumb17.png" border="0" alt="image" width="823" height="594" /></a>
<h2>But how bad is this?</h2>
That is a fair question as well.  Truthfully, it depends.  I know that is my stock answer, but I’m talking about how much this will affect the user.  It could be nothing.  But if you have a lot of JavaScript on the page, it could be significant.   Potentially it could be as annoying as a blink tag.  Even worse it might be on par with ESPN and their auto-playing videos.   But, if we are talking about 10-20 lines of script, there could be no change at all in render time. I will say this, by moving the script to the bottom of the page I have taken pages that were not usable for 10 seconds, improved it to moments (the page had a LOT of JavaScript…and it was a very noble cause).
<h2>What else should I be doing that I’m not?</h2>
This one is easy.  Run all of your pages through <a href="http://developer.yahoo.com/yslow/">YSlow</a> and <a href="http://code.google.com/speed/page-speed/">PageSpeed</a> (you need FireFox and <a href="http://getfirebug.com/">Firebug</a> installed for this) and find out.  Also, you don’t have to be perfect as far as these tools are concerned.  Some of the rule are probably not practical either (the “You should be using a CDN for images” rule comes to mind).  But it is good to know where you can improve.  PageSpeed has a number of really nice tools as well.  It will return you properly sized images, and compressed CSS and JavaScript if you ask it.]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/03/30/your-javascript-goes-where/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Introducing oEmbed</title>
		<link>http://elegantcode.com/2010/03/05/introducing-oembed/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=introducing-oembed</link>
		<comments>http://elegantcode.com/2010/03/05/introducing-oembed/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 06:12:08 +0000</pubDate>
		<dc:creator>cory.isakson</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[WebServices]]></category>
		<category><![CDATA[oembed]]></category>

		<guid isPermaLink="false">http://elegantcode.com/?p=3325</guid>
		<description><![CDATA[Gadgets, widgets, flash, ActiveX, Silverlight, json, xml With all of the competing technologies for content embedding and resource sharing on the web it can be difficult to determine which options to use.  Have you ever wished that you could embed YouTube videos and Flickr photos into your site just by knowing the consumer friendly URLi’s [...]]]></description>
			<content:encoded><![CDATA[Gadgets, widgets, flash, ActiveX, Silverlight, json, xml

With all of the competing technologies for content embedding and resource sharing on the web it can be difficult to determine which options to use.  Have you ever wished that you could embed YouTube videos and Flickr photos into your site just by knowing the consumer friendly URLi’s to them?  That is exactly what <a href="http://oembed.com">oEmbed</a> provides.  I would like to introduce you to the basics of the specification.  I hope the simplicity encourages you to support it as a provider and as a consumer when embedding resources from other providers.  Many popular sites already support it!
<blockquote>oEmbed is a format for allowing an embedded representation of a URL on third party sites. The simple API allows a website to display embedded content (such as photos or videos) when a user posts a link to that resource, without having to parse the resource directly.</blockquote>
Lets take a look at each side of a provider and consumer scenario to illustrate how oEmbed provides and elegant solution for each.
<blockquote>Providers must specify one or more URL scheme and API endpoint pairs. The URL scheme describes which URLs provided by the service may have an embedded representation.</blockquote>
The publisher must determine what scheme(s) they support in very basic format.  Typically the scheme matches URLs that consumers would browse resources at normally.  The YouTube API, for example, supports URLs matching the scheme <a href="http://*.youtube.com/watch">http://*.youtube.com/watch</a>*

The API endpoint is simply an http URL at which consumers request oEmbed representations of the resources you provide.  Most of the current providers offer API endpoints with obvious URL’s like <a title="http://www.youtube.com/oembed" href="http://www.youtube.com/oembed">http://www.youtube.com/oembed</a> and <a title="http://www.flickr.com/services/oembed/" href="http://www.flickr.com/services/oembed/">http://www.flickr.com/services/oembed/</a>.

Once you have the endpoint you just need to host a service there that accepts 4 specific query parameters:

url : The urlencoded url that matches a supported provider defined scheme.
maxwidth : (optional) The maximum width you want for embedding the resource.
maxheight : (optional) The maximum height you want for embedding the resource.
format: (optional) xml or json are the possible values that determine the consumers desired response Content-Type.
<blockquote>Requests sent to the API endpoint must be HTTP GET requests, with all arguments sent as query parameters. All arguments must be urlencoded (as per RFC 1738).</blockquote>
oEmbed consumers make requests for the oEmbed representation of a resource by sending a basic GET request to an API endpoint with url query parameters and any optional parameters they choose.

A request to <a title="http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3D6lbDyXu7gUQ" href="http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3D6lbDyXu7gUQ">http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3D6lbDyXu7gUQ</a> results in a json response:
<pre>{
"provider_url": "http://www.youtube.com/",
"title": "Insert a YouTube Video With oEmbed Wordpress 2.9",
"html": "&lt;object width=\"480\" height=\"295\"&gt;
    &lt;param name=\"movie\" value=\"http://www.youtube.com/v/6lbDyXu7gUQ&amp;fs=1\"&gt;&lt;/param&gt;
    &lt;param name=\"allowFullScreen\" value=\"true\"&gt;&lt;/param&gt;
    &lt;param name=\"allowscriptaccess\" value=\"always\"&gt;&lt;/param&gt;
    &lt;embed src=\"http://www.youtube.com/v/6lbDyXu7gUQ&amp;fs=1\" type=\"application/x-shockwave-flash\"
        width=\"480\" height=\"295\" allowscriptaccess=\"always\" allowfullscreen=\"true\"&gt;&lt;/embed&gt;&lt;/object&gt;",
"author_name": "adriarichards", "height": 295, "width": 480, "version": "1.0",
"author_url": "http://www.youtube.com/user/adriarichards",
"provider_name": "YouTube",
"type": "video"
}</pre>
Note the html property.  It contains everything you need to embed the video.  If this installation of WordPress was running version 2.9 I could paste a YouTube URL here and it would automatically get embeded as described in the video <a href="http://www.youtube.com/watch?v=6lbDyXu7gUQ">Insert a YouTube Video With oEmbed Wordpress 2.9</a>

oEmbed supports 4 result types including video, photo, link and rich.  The rich type allows for just about any html to be returned and thus embedded.
<blockquote>Consumers may wish to load the HTML in an off-domain iframe to avoid XSS vulnerabilities.</blockquote>
To learn more and see a list of some current providers check it out at:

<a title="http://oembed.com/" href="http://oembed.com/">http://oembed.com/</a>

And for a few more implementations check out <a title="http://oohembed.com/" href="http://oohembed.com/">http://oohembed.com/</a>

I look forward to hearing how you end up using oEmbed!]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/03/05/introducing-oembed/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JetBrains Web IDE</title>
		<link>http://elegantcode.com/2010/01/29/jetbrains-web-ide/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=jetbrains-web-ide</link>
		<comments>http://elegantcode.com/2010/01/29/jetbrains-web-ide/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 21:03:26 +0000</pubDate>
		<dc:creator>Jan Van Ryswyck</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/01/29/jetbrains-web-ide/</guid>
		<description><![CDATA[As I already mentioned in a previous blog post, I’m kind of (re-)learning HTML and CSS. The best way for me to pick things up again is by getting my hands dirty and work myself through a simple example. So I decided to work on some sort of prototype of a web application without using [...]]]></description>
			<content:encoded><![CDATA[<p>As I already mentioned in a <a href="http://elegantcode.com/2010/01/26/css-basics-the-box-model/">previous blog post</a>, I’m kind of (re-)learning HTML and CSS. The best way for me to pick things up again is by getting my hands dirty and work myself through a simple example. So I decided to work on some sort of prototype of a web application without using any web framework like ASP.NET MVC, Fubu MVC, Ruby on Rails, etc. … Just plain old HTML and CSS, like the Internet gods intended. I also didn’t want to suck all the fun out of it either, so I decided to use <a href="http://www.jetbrains.com/webide/index.html">Web IDE</a> from <a href="http://www.jetbrains.com/index.html">JetBrains</a> as my IDE for churning out this prototype. </p>  <p>I must say that I was pleasantly surprised by some of the features that this IDE has to offer. The first and most obvious one is probably intellisense that just works as expected.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/01/image9.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/01/image_thumb9.png" width="553" height="385" /></a> </p>  <p>Also notice the on-the-fly code inspection (colored marker bar on the right) that should be familiar when you’re a Resharper addict like me. Web IDE provides W3C XHTML/CSS validation while working in the editor which is really useful. </p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/01/image10.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/01/image_thumb10.png" width="548" height="381" /></a> </p>  <p>Being the uncertain type, it was also nice to see all the familiar refactoring features from Resharper being available as well. Renaming a class or id is just a breeze. All the corresponding HTML or CSS files are consistently updated.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/01/image11.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/01/image_thumb11.png" width="546" height="382" /></a> </p>  <p>Navigation is there as well (CTRL-N and CTRL-SHIFT-N).</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/01/image12.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/01/image_thumb12.png" width="543" height="378" /></a> </p>  <p>This looks just like <a href="http://www.jetbrains.com/resharper/index.html">Resharper</a> for web developers, but there’s more. At first, I had all the HTML and CSS files including all the image file in the root folder of the project. I wanted to divide and conquer by putting the images and CSS files into their own separate folder. As I prepared myself to change all the references in the HTML files, Web IDE did that all for me when I dragged the files to their final destination. Now I didn’t had to go over all the HTML files and manually change the links. How cool is that!</p>  <p>Web IDE also provides source-control integration Subversion, Git, Perforce, etc … and that’s just the tip of the iceberg. While working on the prototype of the web application, I mostly focused on the layout and not so much on the behavior so I didn’t use much of the JavaScript capabilities. But I was told that it is comparable with the JavaScript features in <a href="http://www.jetbrains.com/ruby/index.html">RubyMine</a> as described by Peter in <a href="http://peter.worksontheweb.net/post/An-alternative-to-editing-JavaScript-in-Visual-Studio-RubyMine.aspx">this blog post</a>. This is something that I’m going to explore when I start learning more about JavaScript :-). </p>  <p>Although being the first version and still in beta, the IDE seems pretty stable and I couldn’t notice any performance hiccups so far (which <a href="http://davybrion.com/blog/2010/01/i-still-have-low-expectations-for-visual-studio-2010/">cannot be said for all IDE’s</a> these days). </p>  <p>I do hope that there will be some support for ASP.NET or other view engines like <a href="http://sparkviewengine.com/">Spark</a>, <a href="http://nvelocity.sourceforge.net/">NVelocity</a>, etc. … in future versions. In fact, I still silently wish that JetBrains would come up with an IDE for .NET. Being realistic about it, I don’t have high hopes for something like that coming out but it would totally rock if they decided to build one. Sweet dreams :-)</p>  <p>Bottom line, when you’re doing web development in Visual Studio, make sure to also check out Web IDE. It will probably help you to become more productive along the way.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/01/29/jetbrains-web-ide/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Playing with JQuery Validation library</title>
		<link>http://elegantcode.com/2009/09/27/playing-with-jquery-validation-library/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=playing-with-jquery-validation-library</link>
		<comments>http://elegantcode.com/2009/09/27/playing-with-jquery-validation-library/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 04:21:16 +0000</pubDate>
		<dc:creator>Chris Brandsma</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JQuery]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/09/27/playing-with-jquery-validation-library/</guid>
		<description><![CDATA[New job (2 weeks in), new responsibilities, new tools to play with.&#160; Amazingly (for me), one of the new tools is the JQuery Validation Library.&#160; My diving into this also coincides with ScottGu’s announcement that Microsoft is creating their own CDN for JQuery and JQuery Validation.&#160; Bad news is that this means I’m behind.&#160; That [...]]]></description>
			<content:encoded><![CDATA[<p>New job (2 weeks in), new responsibilities, new tools to play with.&#160; Amazingly (for me), one of the new tools is the <a href="http://docs.jquery.com/Plugins/Validation">JQuery Validation Library</a>.&#160; My diving into this also coincides with ScottGu’s announcement that Microsoft is creating their own <a href="http://weblogs.asp.net/scottgu/archive/2009/09/15/announcing-the-microsoft-ajax-cdn.aspx">CDN for JQuery and JQuery Validation</a>.&#160; </p>  <p>Bad news is that this means I’m behind.&#160; That sucks.&#160; I was using JQuery MONTHS before Microsoft officially started supporting it (at least 6 months – but I’m too lazy to look it up).&#160; Anyway, now you can use Microsoft’s bandwidth to get JQuery to your customer’s browser with this line:</p>  <p>&lt;script src=&quot;http://ajax.microsoft.com/ajax/jquery/jquery-1.3.2.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</p>  <p>And you can add the JQuery Validation library like this: </p>  <p>&lt;script src=&quot;http://ajax.microsoft.com/ajax/jquery.validate/1.5.5/jquery.validate.js&quot; type=”text/javascript”&gt;&lt;/script&gt;</p>  <p>Note: see those end tags, great annoyance of my life, but you have to have them, you can’t do &lt;script src=”http://…” /&gt;.&#160; That sucks, but I’m learning to live with it.</p>  <p>Anyway, back to validation.</p>  <p>The more I play with this library, the more I like it.&#160; It is very configurable, easily style-able, the documentation isn’t half bad, and the code is readable.</p>  <h2>Getting Started with JQuery Validation:</h2>  <p><strong>The JavaScript Way:</strong>&#160; OK, assuming you have JQuery and the JQuery Validation library included, lets start with a simple customer form:</p>  <p></p>  <div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">   <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">     <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">form</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;CustomerForm&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;firstNameEdit&quot;</span><span style="color: #0000ff">&gt;</span>First Name:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;firstNameEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;LastNameEdit&quot;</span><span style="color: #0000ff">&gt;</span>Last Name:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;LastNameEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;EmailEdit&quot;</span><span style="color: #0000ff">&gt;</span>Email:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12">  12:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;EmailEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13">  13:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14">  14:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum15">  15:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">button</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;submit&quot;</span><span style="color: #0000ff">&gt;</span>Submit<span style="color: #0000ff">&lt;/</span><span style="color: #800000">button</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum16">  16:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum17">  17:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">form</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF--></div>
</div>

<p>Nothing special there.&#160; Just a bunch of inputs and labels.&#160; If you hit the submit button, a postback is fired and the data is sent back to the server.</p>

<p>But, business requirements dictate that all fields are required.&#160; Simple enough, using JQuery the hookup looks like this:</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> $(<span style="color: #006080">&quot;#CustomerForm&quot;</span>).validate({</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span>     rules: {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span>       FirstNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>       LastNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>       EmailEdit: { required: <span style="color: #0000ff">true</span>, email:<span style="color: #0000ff">true</span> }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>     }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span> });</pre>
<!--CRLF--></div>
</div>

<p>OK, the first name, last name, and email will now be required.&#160; I also threw a little extra in there: email validation.&#160; If you submit the form like this will be added after any of the required fields:</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> &lt;label <span style="color: #0000ff">class</span>=<span style="color: #006080">&quot;error&quot;</span> <span style="color: #0000ff">for</span>=<span style="color: #006080">&quot;FirstName&quot;</span> generated=<span style="color: #006080">&quot;true&quot;</span>&gt;This field <span style="color: #0000ff">is</span> required.&lt;/label&gt;</pre>
<!--CRLF--></div>
</div>

<p>Key part there is the ‘error’ css class which is great for styling the messages.&#160; So you can use the ‘label.error’ in your css class.</p>

<h2>Another way</h2>

<p>You can also use css classes to setup which fields are required.&#160; It is a nice and simple way to hook everything up, but it is not as easily configurable (as we will see in a moment):</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">form</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;CustomerForm&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;FirstNameEdit&quot;</span><span style="color: #0000ff">&gt;</span>First Name:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;FirstNameEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot;</span> class=”required”<span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;LastNameEdit&quot;</span><span style="color: #0000ff">&gt;</span>Last Name:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;LastNameEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot; class=”required”</span> <span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;EmailEdit&quot;</span><span style="color: #0000ff">&gt;</span>Email:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12">  12:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;EmailEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot;</span> class=”required email”<span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13">  13:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14">  14:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum15">  15:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">button</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;submit&quot;</span><span style="color: #0000ff">&gt;</span>Submit<span style="color: #0000ff">&lt;/</span><span style="color: #800000">button</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum16">  16:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum17">  17:</span> <span style="color: #0000ff">&lt;/form</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF--></div>
</div>

<p>The the Javascript is actually much simpler:</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> $(<span style="color: #006080">&quot;CustomerForm&quot;</span>).validate();</pre>
<!--CRLF--></div>
</div>

<p>And you will get the same results.&#160; But, the rest of the samples will use the prior code setup.&#160; Also note: you can mix and match the css style with the JavaScript style.</p>

<h2>Moving the message</h2>

<p>Next problem you might encounter is you want to move the messages to another part of the screen.&#160; Remember, default behavior is the messages go next to the control.</p>

<p>To solve this we will add a div to the page:</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 31px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">div</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;RegisterErrors&quot;</span> <span style="color: #ff0000">style</span><span style="color: #0000ff">=&quot;display:none&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF--></div>
</div>

<p>I can setup the Validation library to use this by going back to the validate method and adding errorLabelContainer directive.</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> $(“#CustomerForm”).validate({</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> <strong>errorLabelContainer: $(<span style="color: #006080">&quot;#RegisterErrors&quot;</span>),</strong></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> rules: {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>         FirstNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>         LastNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>         EmailEdit: { required: <span style="color: #0000ff">true</span>, email: <span style="color: #0000ff">true</span> }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>     }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span> });</pre>
<!--CRLF--></div>
</div>

<p>Now this is great, but there is still a problem.&#160; Each of the messages will be “This field is required”.&#160; That doesn’t say which field is the problem.&#160; Lets add custom messages for each field.</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> </pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span>     $(<span style="color: #006080">&quot;#CustomerForm&quot;</span>).validate({</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span>     errorLabelContainer: $(<span style="color: #006080">&quot;#RegisterErrors&quot;</span>),</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>     rules: {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>             FirstNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>             LastNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>             EmailEdit: { required: <span style="color: #0000ff">true</span>, email: <span style="color: #0000ff">true</span> }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span>         },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span>         messages: {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span>             FirstNameEdit: <span style="color: #006080">&quot;First name is required&quot;</span>,</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span>             LastNameEdit: <span style="color: #006080">&quot;Last name is required&quot;</span>,</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12">  12:</span>             EmailEdit: <span style="color: #006080">&quot;Valid email address is required&quot;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13">  13:</span>         }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14">  14:</span>     });</pre>
<!--CRLF--></div>
</div>

<p></p>

<p>Which then gives better messages.</p>

<h2>For next time</h2>

<p>Ok, this is not all the JQuery Validation library can do, there is a lot more, but this is enough for now.&#160; Next post will show how to validate fields using web service results, and various callbacks that can be used to customize the library.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/09/27/playing-with-jquery-validation-library/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>FireFox+Firebug vs IE8 Developer Toolbar</title>
		<link>http://elegantcode.com/2010/03/05/introducing-oembed/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=introducing-oembed</link>
		<comments>http://elegantcode.com/2010/03/05/introducing-oembed/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 06:12:08 +0000</pubDate>
		<dc:creator>cory.isakson</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[WebServices]]></category>
		<category><![CDATA[oembed]]></category>

		<guid isPermaLink="false">http://elegantcode.com/?p=3325</guid>
		<description><![CDATA[Gadgets, widgets, flash, ActiveX, Silverlight, json, xml With all of the competing technologies for content embedding and resource sharing on the web it can be difficult to determine which options to use.  Have you ever wished that you could embed YouTube videos and Flickr photos into your site just by knowing the consumer friendly URLi’s [...]]]></description>
			<content:encoded><![CDATA[Gadgets, widgets, flash, ActiveX, Silverlight, json, xml

With all of the competing technologies for content embedding and resource sharing on the web it can be difficult to determine which options to use.  Have you ever wished that you could embed YouTube videos and Flickr photos into your site just by knowing the consumer friendly URLi’s to them?  That is exactly what <a href="http://oembed.com">oEmbed</a> provides.  I would like to introduce you to the basics of the specification.  I hope the simplicity encourages you to support it as a provider and as a consumer when embedding resources from other providers.  Many popular sites already support it!
<blockquote>oEmbed is a format for allowing an embedded representation of a URL on third party sites. The simple API allows a website to display embedded content (such as photos or videos) when a user posts a link to that resource, without having to parse the resource directly.</blockquote>
Lets take a look at each side of a provider and consumer scenario to illustrate how oEmbed provides and elegant solution for each.
<blockquote>Providers must specify one or more URL scheme and API endpoint pairs. The URL scheme describes which URLs provided by the service may have an embedded representation.</blockquote>
The publisher must determine what scheme(s) they support in very basic format.  Typically the scheme matches URLs that consumers would browse resources at normally.  The YouTube API, for example, supports URLs matching the scheme <a href="http://*.youtube.com/watch">http://*.youtube.com/watch</a>*

The API endpoint is simply an http URL at which consumers request oEmbed representations of the resources you provide.  Most of the current providers offer API endpoints with obvious URL’s like <a title="http://www.youtube.com/oembed" href="http://www.youtube.com/oembed">http://www.youtube.com/oembed</a> and <a title="http://www.flickr.com/services/oembed/" href="http://www.flickr.com/services/oembed/">http://www.flickr.com/services/oembed/</a>.

Once you have the endpoint you just need to host a service there that accepts 4 specific query parameters:

url : The urlencoded url that matches a supported provider defined scheme.
maxwidth : (optional) The maximum width you want for embedding the resource.
maxheight : (optional) The maximum height you want for embedding the resource.
format: (optional) xml or json are the possible values that determine the consumers desired response Content-Type.
<blockquote>Requests sent to the API endpoint must be HTTP GET requests, with all arguments sent as query parameters. All arguments must be urlencoded (as per RFC 1738).</blockquote>
oEmbed consumers make requests for the oEmbed representation of a resource by sending a basic GET request to an API endpoint with url query parameters and any optional parameters they choose.

A request to <a title="http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3D6lbDyXu7gUQ" href="http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3D6lbDyXu7gUQ">http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3D6lbDyXu7gUQ</a> results in a json response:
<pre>{
"provider_url": "http://www.youtube.com/",
"title": "Insert a YouTube Video With oEmbed Wordpress 2.9",
"html": "&lt;object width=\"480\" height=\"295\"&gt;
    &lt;param name=\"movie\" value=\"http://www.youtube.com/v/6lbDyXu7gUQ&amp;fs=1\"&gt;&lt;/param&gt;
    &lt;param name=\"allowFullScreen\" value=\"true\"&gt;&lt;/param&gt;
    &lt;param name=\"allowscriptaccess\" value=\"always\"&gt;&lt;/param&gt;
    &lt;embed src=\"http://www.youtube.com/v/6lbDyXu7gUQ&amp;fs=1\" type=\"application/x-shockwave-flash\"
        width=\"480\" height=\"295\" allowscriptaccess=\"always\" allowfullscreen=\"true\"&gt;&lt;/embed&gt;&lt;/object&gt;",
"author_name": "adriarichards", "height": 295, "width": 480, "version": "1.0",
"author_url": "http://www.youtube.com/user/adriarichards",
"provider_name": "YouTube",
"type": "video"
}</pre>
Note the html property.  It contains everything you need to embed the video.  If this installation of WordPress was running version 2.9 I could paste a YouTube URL here and it would automatically get embeded as described in the video <a href="http://www.youtube.com/watch?v=6lbDyXu7gUQ">Insert a YouTube Video With oEmbed Wordpress 2.9</a>

oEmbed supports 4 result types including video, photo, link and rich.  The rich type allows for just about any html to be returned and thus embedded.
<blockquote>Consumers may wish to load the HTML in an off-domain iframe to avoid XSS vulnerabilities.</blockquote>
To learn more and see a list of some current providers check it out at:

<a title="http://oembed.com/" href="http://oembed.com/">http://oembed.com/</a>

And for a few more implementations check out <a title="http://oohembed.com/" href="http://oohembed.com/">http://oohembed.com/</a>

I look forward to hearing how you end up using oEmbed!]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/03/05/introducing-oembed/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Elegant Code &#187; html</title>
	<atom:link href="http://elegantcode.com/category/html/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com</link>
	<description></description>
	<lastBuildDate>Tue, 15 May 2012 10:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>The Web is Not Platform Independent</title>
		<link>http://elegantcode.com/2010/08/22/the-web-is-not-platform-independent/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-web-is-not-platform-independent</link>
		<comments>http://elegantcode.com/2010/08/22/the-web-is-not-platform-independent/#comments</comments>
		<pubDate>Sun, 22 Aug 2010 20:16:32 +0000</pubDate>
		<dc:creator>John Sonmez</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/08/22/the-web-is-not-platform-independent/</guid>
		<description><![CDATA[There was a time when you wrote a web site and you targeted IE6. That time has long passed. When you really only had to target IE6, you could pretend the web was platform independent. The truth is now the web is neither, nor will ever be platform independent.&#160; It’s just an illusion based on [...]]]></description>
			<content:encoded><![CDATA[<p>There was a time when you wrote a web site and you targeted IE6.</p>  <p>That time has long passed.</p>  <p>When you really only had to target IE6, you could pretend the web was platform independent.</p>  <p>The truth is now the web is neither, nor will ever be platform independent.&#160; It’s just an illusion based on the simple notion that browsers basically just render HTML.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/08/pegi.jpg"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="pegi" border="0" alt="pegi" src="http://elegantcode.com/wp-content/uploads/2010/08/pegi_thumb.jpg" width="438" height="517" /></a></p>  <h2>How many platforms are there then?</h2>  <p>This is a surprisingly difficult question to answer.</p>  <p>Back before the web really took off there were basically 3 platforms to develop an app for: Windows; Unix/Linux; and Mac.</p>  <p>When we answer this question for the web, really we have to look at browsers as if they are the operating system.&#160; Since the same browser exists on multiple base OS’s but could be different, we have to count each combination of browser and OS as a potentially separate version.</p>  <p>Windows: IE6, IE7, IE8, IE9 (beta), Firefox, Chrome, Safari</p>  <p>OSX: IE, Firefox, Safari (more?)</p>  <p>Linux: Firefox, Chrome</p>  <p>Android: Webkit</p>  <p>iPad, iPhone: Safari</p>  <p>I don’t have nearly every combination listed, but this is what I would consider a good coverage for any kind of public facing website.</p>  <p>Oh, don’t forget to cross this again with localization and globalization, because you might have a localization problem that only happens in a certain language in a certain browser on a certain OS.</p>  <h2>Not just rendering level differences</h2>  <p>It is also very interesting to consider that a web developer now has to consider how their site will not just render, but be used on a mobile platform.&#160; </p>  <p>Consider how Google released an iPad version of Gmail.&#160; And although, you may not really care if your site works on an iPhone or an Android phone, you probably should start caring about how it works on tablets like the iPad, because that market is only growing. </p>  <p><strong>If you have a website that doesn’t work on someone’s iPad when they are shopping online, do you think they will get up, go turn on the computer, and go to your site to make the purchase or they will buy from a different site with a few touches?</strong></p>  <p>With a phone size resolution, the considerations are even more important.</p>  <h2>Tools help me make the web platform independent</h2>  <p>No tool exists right now that can handle the non-technical aspects of platform independence for your web application, but let us imagine for a second that a library like JQuery really made your javascript platform independent.</p>  <p>If we were to hold onto that shaky assumption, we would need to make sure that we never wrote javascript that wasn’t written through the JQuery API.&#160; (Which happens to be an extremely leaky abstraction over javascript, CSS, and the DOM.) We would still have to make sure our HTML and CSS tags were platform independent.</p>  <p>So even if we could get parts of our development to be mostly platform independent, we would still need to test on all of the major platforms, because we could not rely on the platform independence.</p>  <p>Now, don’t get me wrong here.&#160; I love JQuery.&#160; It makes the job of a web developer so much easier.&#160; But, there is an important distinction.&#160; <strong>APIs and libraries like JQuery make it easier to write platform independent web code, but they don’t make our code platform independent.</strong></p>  <h2>What does all this mean?</h2>  <p>We’ve gotten to the point where the most platform independent technology you can use is either Flash or Silverlight.</p>  <p>I’m not sure if this is the future of development, but it very well might be.</p>  <p>One important point to draw from this realization is that we shouldn’t necessarily choose to make our application a web application, because we need it to be platform independent.&#160; It seems like about 5 years ago, the web became the default choice, because it was better to have platform independence than a rich UI.</p>  <p>Hopefully, for the sake of web developers some of these paths die off or converge, or that standards compliance becomes so good that you could really write code for one browser and expect it to work on all the others.</p>  <h6>As always, you can subscribe to this <a href="http://feeds2.feedburner.com/ElegantCode">RSS feed</a> to follow my posts on elegant code.&#160; Feel free to check out my main personal blog at <a href="http://simpleprogrammer.com">http://simpleprogrammer.com</a>, which has a wider range of posts, updated 2-3 times a week.&#160; Also, you can follow me on twitter <a href="http://twitter.com/jsonmez">here</a>.</h6>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/08/22/the-web-is-not-platform-independent/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Your JavaScript goes WHERE?</title>
		<link>http://elegantcode.com/2010/03/30/your-javascript-goes-where/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=your-javascript-goes-where</link>
		<comments>http://elegantcode.com/2010/03/30/your-javascript-goes-where/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 03:35:37 +0000</pubDate>
		<dc:creator>Chris Brandsma</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/03/30/your-javascript-goes-where/</guid>
		<description><![CDATA[Let me start by saying that I was not trying to be controversial.  I was at Boise Code Camp giving a session about Asp.Net MVC, and I happened to mention that JavaScript was supposed to go at the bottom of your page.  Plus, I said this in a “of course you all know this already” [...]]]></description>
			<content:encoded><![CDATA[Let me start by saying that I was not trying to be controversial.  I was at Boise Code Camp giving a session about Asp.Net MVC, and I happened to mention that JavaScript was supposed to go at the bottom of your page.  Plus, I said this in a “of course you all know this already” type of voice, thinking this needed no further explanation.

Then the hands started raising.  Quickly, I might add.  I had to explain myself.  Yes, JavaScript goes at the bottom of your page.  Yes, I realize that we were all taught, back in the day, that JavaScript’s true home was in the &lt;head&gt; element.  In fact, <a href="http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery">many sample pages still show JavaScript at the top</a>.  But we probably learned that ten years ago, you have to think a few things have changed…except IE6 – that sucker is going to live forever!  Anyway, I’m not the type that like to stand up in a crowd and say “everything you, and everyone you know, is doing is wrong” (I’m not that smart).  And if I do, I want to come with some substantial proof.

To start, <a href="http://www.w3.org/TR/REC-html40/interact/scripts.html#h-18.2.1">where does the w3c say the SCRIPT element is supposed to go?</a>  If you read the document in the link, SCRIPT can live in either the HEAD or the BODY elements. So technically, both places are legal.  I am stating this so that no one come back and tells me I’m breaking any fundamental web rules.  If the w3c says it is ok, then it is ok darn it.
<h2>But why the bottom of the page? </h2>
That one is slightly harder to explain.  But here are the basics:  when a browser loads a document there are only so many thread for processing the document and download all the other crap that you put on the page <a href="http://theoatmeal.com/comics/design_hell">so it pops</a> (so, images and css, not to mention the bagillion font tags that Word likes to put in html).  There is also an unwritten rule that JavaScript should enhance the page after it is loaded.  So any time the browser spends parsing JavaScript is time it could be using to make the page look right.  Also, with some browsers, when the browser is loading JavaScript, ALL OTHER ACTIVITY STOPS.  Nothing else is downloaded, the browser is at a standstill until all the script is parsed – and <a href="http://ejohn.org/blog/javascript-performance-rundown/">you know how fast IE is at JavaScript.</a>

Lets be clear about this “rule”.  <a href="http://developer.yahoo.com/performance/rules.html#js_bottom">I did not make this up.</a>  But there are other ways around the performance penalty, you can also <a href="http://code.google.com/speed/page-speed/docs/payload.html#DeferLoadingJS">defer load</a> your JavaScript.  Also, putting all of the JavaScript into a single, external file is a great idea.  With a external file you get the added benefit of the JavaScript file being cached by the browser (Note: great for the user – pain for your tester.  Repeat after me, “CLEAR YOUR CACHE” often when testing).

OK, so let us review.

<a href="http://elegantcode.com/wp-content/uploads/2010/03/image17.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" src="http://elegantcode.com/wp-content/uploads/2010/03/image_thumb17.png" border="0" alt="image" width="823" height="594" /></a>
<h2>But how bad is this?</h2>
That is a fair question as well.  Truthfully, it depends.  I know that is my stock answer, but I’m talking about how much this will affect the user.  It could be nothing.  But if you have a lot of JavaScript on the page, it could be significant.   Potentially it could be as annoying as a blink tag.  Even worse it might be on par with ESPN and their auto-playing videos.   But, if we are talking about 10-20 lines of script, there could be no change at all in render time. I will say this, by moving the script to the bottom of the page I have taken pages that were not usable for 10 seconds, improved it to moments (the page had a LOT of JavaScript…and it was a very noble cause).
<h2>What else should I be doing that I’m not?</h2>
This one is easy.  Run all of your pages through <a href="http://developer.yahoo.com/yslow/">YSlow</a> and <a href="http://code.google.com/speed/page-speed/">PageSpeed</a> (you need FireFox and <a href="http://getfirebug.com/">Firebug</a> installed for this) and find out.  Also, you don’t have to be perfect as far as these tools are concerned.  Some of the rule are probably not practical either (the “You should be using a CDN for images” rule comes to mind).  But it is good to know where you can improve.  PageSpeed has a number of really nice tools as well.  It will return you properly sized images, and compressed CSS and JavaScript if you ask it.]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/03/30/your-javascript-goes-where/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Introducing oEmbed</title>
		<link>http://elegantcode.com/2010/03/05/introducing-oembed/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=introducing-oembed</link>
		<comments>http://elegantcode.com/2010/03/05/introducing-oembed/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 06:12:08 +0000</pubDate>
		<dc:creator>cory.isakson</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[WebServices]]></category>
		<category><![CDATA[oembed]]></category>

		<guid isPermaLink="false">http://elegantcode.com/?p=3325</guid>
		<description><![CDATA[Gadgets, widgets, flash, ActiveX, Silverlight, json, xml With all of the competing technologies for content embedding and resource sharing on the web it can be difficult to determine which options to use.  Have you ever wished that you could embed YouTube videos and Flickr photos into your site just by knowing the consumer friendly URLi’s [...]]]></description>
			<content:encoded><![CDATA[Gadgets, widgets, flash, ActiveX, Silverlight, json, xml

With all of the competing technologies for content embedding and resource sharing on the web it can be difficult to determine which options to use.  Have you ever wished that you could embed YouTube videos and Flickr photos into your site just by knowing the consumer friendly URLi’s to them?  That is exactly what <a href="http://oembed.com">oEmbed</a> provides.  I would like to introduce you to the basics of the specification.  I hope the simplicity encourages you to support it as a provider and as a consumer when embedding resources from other providers.  Many popular sites already support it!
<blockquote>oEmbed is a format for allowing an embedded representation of a URL on third party sites. The simple API allows a website to display embedded content (such as photos or videos) when a user posts a link to that resource, without having to parse the resource directly.</blockquote>
Lets take a look at each side of a provider and consumer scenario to illustrate how oEmbed provides and elegant solution for each.
<blockquote>Providers must specify one or more URL scheme and API endpoint pairs. The URL scheme describes which URLs provided by the service may have an embedded representation.</blockquote>
The publisher must determine what scheme(s) they support in very basic format.  Typically the scheme matches URLs that consumers would browse resources at normally.  The YouTube API, for example, supports URLs matching the scheme <a href="http://*.youtube.com/watch">http://*.youtube.com/watch</a>*

The API endpoint is simply an http URL at which consumers request oEmbed representations of the resources you provide.  Most of the current providers offer API endpoints with obvious URL’s like <a title="http://www.youtube.com/oembed" href="http://www.youtube.com/oembed">http://www.youtube.com/oembed</a> and <a title="http://www.flickr.com/services/oembed/" href="http://www.flickr.com/services/oembed/">http://www.flickr.com/services/oembed/</a>.

Once you have the endpoint you just need to host a service there that accepts 4 specific query parameters:

url : The urlencoded url that matches a supported provider defined scheme.
maxwidth : (optional) The maximum width you want for embedding the resource.
maxheight : (optional) The maximum height you want for embedding the resource.
format: (optional) xml or json are the possible values that determine the consumers desired response Content-Type.
<blockquote>Requests sent to the API endpoint must be HTTP GET requests, with all arguments sent as query parameters. All arguments must be urlencoded (as per RFC 1738).</blockquote>
oEmbed consumers make requests for the oEmbed representation of a resource by sending a basic GET request to an API endpoint with url query parameters and any optional parameters they choose.

A request to <a title="http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3D6lbDyXu7gUQ" href="http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3D6lbDyXu7gUQ">http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3D6lbDyXu7gUQ</a> results in a json response:
<pre>{
"provider_url": "http://www.youtube.com/",
"title": "Insert a YouTube Video With oEmbed Wordpress 2.9",
"html": "&lt;object width=\"480\" height=\"295\"&gt;
    &lt;param name=\"movie\" value=\"http://www.youtube.com/v/6lbDyXu7gUQ&amp;fs=1\"&gt;&lt;/param&gt;
    &lt;param name=\"allowFullScreen\" value=\"true\"&gt;&lt;/param&gt;
    &lt;param name=\"allowscriptaccess\" value=\"always\"&gt;&lt;/param&gt;
    &lt;embed src=\"http://www.youtube.com/v/6lbDyXu7gUQ&amp;fs=1\" type=\"application/x-shockwave-flash\"
        width=\"480\" height=\"295\" allowscriptaccess=\"always\" allowfullscreen=\"true\"&gt;&lt;/embed&gt;&lt;/object&gt;",
"author_name": "adriarichards", "height": 295, "width": 480, "version": "1.0",
"author_url": "http://www.youtube.com/user/adriarichards",
"provider_name": "YouTube",
"type": "video"
}</pre>
Note the html property.  It contains everything you need to embed the video.  If this installation of WordPress was running version 2.9 I could paste a YouTube URL here and it would automatically get embeded as described in the video <a href="http://www.youtube.com/watch?v=6lbDyXu7gUQ">Insert a YouTube Video With oEmbed Wordpress 2.9</a>

oEmbed supports 4 result types including video, photo, link and rich.  The rich type allows for just about any html to be returned and thus embedded.
<blockquote>Consumers may wish to load the HTML in an off-domain iframe to avoid XSS vulnerabilities.</blockquote>
To learn more and see a list of some current providers check it out at:

<a title="http://oembed.com/" href="http://oembed.com/">http://oembed.com/</a>

And for a few more implementations check out <a title="http://oohembed.com/" href="http://oohembed.com/">http://oohembed.com/</a>

I look forward to hearing how you end up using oEmbed!]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/03/05/introducing-oembed/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JetBrains Web IDE</title>
		<link>http://elegantcode.com/2010/01/29/jetbrains-web-ide/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=jetbrains-web-ide</link>
		<comments>http://elegantcode.com/2010/01/29/jetbrains-web-ide/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 21:03:26 +0000</pubDate>
		<dc:creator>Jan Van Ryswyck</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/01/29/jetbrains-web-ide/</guid>
		<description><![CDATA[As I already mentioned in a previous blog post, I’m kind of (re-)learning HTML and CSS. The best way for me to pick things up again is by getting my hands dirty and work myself through a simple example. So I decided to work on some sort of prototype of a web application without using [...]]]></description>
			<content:encoded><![CDATA[<p>As I already mentioned in a <a href="http://elegantcode.com/2010/01/26/css-basics-the-box-model/">previous blog post</a>, I’m kind of (re-)learning HTML and CSS. The best way for me to pick things up again is by getting my hands dirty and work myself through a simple example. So I decided to work on some sort of prototype of a web application without using any web framework like ASP.NET MVC, Fubu MVC, Ruby on Rails, etc. … Just plain old HTML and CSS, like the Internet gods intended. I also didn’t want to suck all the fun out of it either, so I decided to use <a href="http://www.jetbrains.com/webide/index.html">Web IDE</a> from <a href="http://www.jetbrains.com/index.html">JetBrains</a> as my IDE for churning out this prototype. </p>  <p>I must say that I was pleasantly surprised by some of the features that this IDE has to offer. The first and most obvious one is probably intellisense that just works as expected.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/01/image9.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/01/image_thumb9.png" width="553" height="385" /></a> </p>  <p>Also notice the on-the-fly code inspection (colored marker bar on the right) that should be familiar when you’re a Resharper addict like me. Web IDE provides W3C XHTML/CSS validation while working in the editor which is really useful. </p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/01/image10.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/01/image_thumb10.png" width="548" height="381" /></a> </p>  <p>Being the uncertain type, it was also nice to see all the familiar refactoring features from Resharper being available as well. Renaming a class or id is just a breeze. All the corresponding HTML or CSS files are consistently updated.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/01/image11.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/01/image_thumb11.png" width="546" height="382" /></a> </p>  <p>Navigation is there as well (CTRL-N and CTRL-SHIFT-N).</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/01/image12.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/01/image_thumb12.png" width="543" height="378" /></a> </p>  <p>This looks just like <a href="http://www.jetbrains.com/resharper/index.html">Resharper</a> for web developers, but there’s more. At first, I had all the HTML and CSS files including all the image file in the root folder of the project. I wanted to divide and conquer by putting the images and CSS files into their own separate folder. As I prepared myself to change all the references in the HTML files, Web IDE did that all for me when I dragged the files to their final destination. Now I didn’t had to go over all the HTML files and manually change the links. How cool is that!</p>  <p>Web IDE also provides source-control integration Subversion, Git, Perforce, etc … and that’s just the tip of the iceberg. While working on the prototype of the web application, I mostly focused on the layout and not so much on the behavior so I didn’t use much of the JavaScript capabilities. But I was told that it is comparable with the JavaScript features in <a href="http://www.jetbrains.com/ruby/index.html">RubyMine</a> as described by Peter in <a href="http://peter.worksontheweb.net/post/An-alternative-to-editing-JavaScript-in-Visual-Studio-RubyMine.aspx">this blog post</a>. This is something that I’m going to explore when I start learning more about JavaScript :-). </p>  <p>Although being the first version and still in beta, the IDE seems pretty stable and I couldn’t notice any performance hiccups so far (which <a href="http://davybrion.com/blog/2010/01/i-still-have-low-expectations-for-visual-studio-2010/">cannot be said for all IDE’s</a> these days). </p>  <p>I do hope that there will be some support for ASP.NET or other view engines like <a href="http://sparkviewengine.com/">Spark</a>, <a href="http://nvelocity.sourceforge.net/">NVelocity</a>, etc. … in future versions. In fact, I still silently wish that JetBrains would come up with an IDE for .NET. Being realistic about it, I don’t have high hopes for something like that coming out but it would totally rock if they decided to build one. Sweet dreams :-)</p>  <p>Bottom line, when you’re doing web development in Visual Studio, make sure to also check out Web IDE. It will probably help you to become more productive along the way.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/01/29/jetbrains-web-ide/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Playing with JQuery Validation library</title>
		<link>http://elegantcode.com/2009/09/27/playing-with-jquery-validation-library/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=playing-with-jquery-validation-library</link>
		<comments>http://elegantcode.com/2009/09/27/playing-with-jquery-validation-library/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 04:21:16 +0000</pubDate>
		<dc:creator>Chris Brandsma</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JQuery]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/09/27/playing-with-jquery-validation-library/</guid>
		<description><![CDATA[New job (2 weeks in), new responsibilities, new tools to play with.&#160; Amazingly (for me), one of the new tools is the JQuery Validation Library.&#160; My diving into this also coincides with ScottGu’s announcement that Microsoft is creating their own CDN for JQuery and JQuery Validation.&#160; Bad news is that this means I’m behind.&#160; That [...]]]></description>
			<content:encoded><![CDATA[<p>New job (2 weeks in), new responsibilities, new tools to play with.&#160; Amazingly (for me), one of the new tools is the <a href="http://docs.jquery.com/Plugins/Validation">JQuery Validation Library</a>.&#160; My diving into this also coincides with ScottGu’s announcement that Microsoft is creating their own <a href="http://weblogs.asp.net/scottgu/archive/2009/09/15/announcing-the-microsoft-ajax-cdn.aspx">CDN for JQuery and JQuery Validation</a>.&#160; </p>  <p>Bad news is that this means I’m behind.&#160; That sucks.&#160; I was using JQuery MONTHS before Microsoft officially started supporting it (at least 6 months – but I’m too lazy to look it up).&#160; Anyway, now you can use Microsoft’s bandwidth to get JQuery to your customer’s browser with this line:</p>  <p>&lt;script src=&quot;http://ajax.microsoft.com/ajax/jquery/jquery-1.3.2.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</p>  <p>And you can add the JQuery Validation library like this: </p>  <p>&lt;script src=&quot;http://ajax.microsoft.com/ajax/jquery.validate/1.5.5/jquery.validate.js&quot; type=”text/javascript”&gt;&lt;/script&gt;</p>  <p>Note: see those end tags, great annoyance of my life, but you have to have them, you can’t do &lt;script src=”http://…” /&gt;.&#160; That sucks, but I’m learning to live with it.</p>  <p>Anyway, back to validation.</p>  <p>The more I play with this library, the more I like it.&#160; It is very configurable, easily style-able, the documentation isn’t half bad, and the code is readable.</p>  <h2>Getting Started with JQuery Validation:</h2>  <p><strong>The JavaScript Way:</strong>&#160; OK, assuming you have JQuery and the JQuery Validation library included, lets start with a simple customer form:</p>  <p></p>  <div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">   <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">     <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">form</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;CustomerForm&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;firstNameEdit&quot;</span><span style="color: #0000ff">&gt;</span>First Name:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;firstNameEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;LastNameEdit&quot;</span><span style="color: #0000ff">&gt;</span>Last Name:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;LastNameEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;EmailEdit&quot;</span><span style="color: #0000ff">&gt;</span>Email:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12">  12:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;EmailEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13">  13:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14">  14:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum15">  15:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">button</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;submit&quot;</span><span style="color: #0000ff">&gt;</span>Submit<span style="color: #0000ff">&lt;/</span><span style="color: #800000">button</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum16">  16:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum17">  17:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">form</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF--></div>
</div>

<p>Nothing special there.&#160; Just a bunch of inputs and labels.&#160; If you hit the submit button, a postback is fired and the data is sent back to the server.</p>

<p>But, business requirements dictate that all fields are required.&#160; Simple enough, using JQuery the hookup looks like this:</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> $(<span style="color: #006080">&quot;#CustomerForm&quot;</span>).validate({</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span>     rules: {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span>       FirstNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>       LastNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>       EmailEdit: { required: <span style="color: #0000ff">true</span>, email:<span style="color: #0000ff">true</span> }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>     }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span> });</pre>
<!--CRLF--></div>
</div>

<p>OK, the first name, last name, and email will now be required.&#160; I also threw a little extra in there: email validation.&#160; If you submit the form like this will be added after any of the required fields:</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> &lt;label <span style="color: #0000ff">class</span>=<span style="color: #006080">&quot;error&quot;</span> <span style="color: #0000ff">for</span>=<span style="color: #006080">&quot;FirstName&quot;</span> generated=<span style="color: #006080">&quot;true&quot;</span>&gt;This field <span style="color: #0000ff">is</span> required.&lt;/label&gt;</pre>
<!--CRLF--></div>
</div>

<p>Key part there is the ‘error’ css class which is great for styling the messages.&#160; So you can use the ‘label.error’ in your css class.</p>

<h2>Another way</h2>

<p>You can also use css classes to setup which fields are required.&#160; It is a nice and simple way to hook everything up, but it is not as easily configurable (as we will see in a moment):</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">form</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;CustomerForm&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;FirstNameEdit&quot;</span><span style="color: #0000ff">&gt;</span>First Name:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;FirstNameEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot;</span> class=”required”<span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;LastNameEdit&quot;</span><span style="color: #0000ff">&gt;</span>Last Name:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;LastNameEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot; class=”required”</span> <span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;EmailEdit&quot;</span><span style="color: #0000ff">&gt;</span>Email:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12">  12:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;EmailEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot;</span> class=”required email”<span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13">  13:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14">  14:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum15">  15:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">button</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;submit&quot;</span><span style="color: #0000ff">&gt;</span>Submit<span style="color: #0000ff">&lt;/</span><span style="color: #800000">button</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum16">  16:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum17">  17:</span> <span style="color: #0000ff">&lt;/form</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF--></div>
</div>

<p>The the Javascript is actually much simpler:</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> $(<span style="color: #006080">&quot;CustomerForm&quot;</span>).validate();</pre>
<!--CRLF--></div>
</div>

<p>And you will get the same results.&#160; But, the rest of the samples will use the prior code setup.&#160; Also note: you can mix and match the css style with the JavaScript style.</p>

<h2>Moving the message</h2>

<p>Next problem you might encounter is you want to move the messages to another part of the screen.&#160; Remember, default behavior is the messages go next to the control.</p>

<p>To solve this we will add a div to the page:</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 31px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">div</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;RegisterErrors&quot;</span> <span style="color: #ff0000">style</span><span style="color: #0000ff">=&quot;display:none&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF--></div>
</div>

<p>I can setup the Validation library to use this by going back to the validate method and adding errorLabelContainer directive.</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> $(“#CustomerForm”).validate({</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> <strong>errorLabelContainer: $(<span style="color: #006080">&quot;#RegisterErrors&quot;</span>),</strong></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> rules: {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>         FirstNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>         LastNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>         EmailEdit: { required: <span style="color: #0000ff">true</span>, email: <span style="color: #0000ff">true</span> }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>     }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span> });</pre>
<!--CRLF--></div>
</div>

<p>Now this is great, but there is still a problem.&#160; Each of the messages will be “This field is required”.&#160; That doesn’t say which field is the problem.&#160; Lets add custom messages for each field.</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> </pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span>     $(<span style="color: #006080">&quot;#CustomerForm&quot;</span>).validate({</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span>     errorLabelContainer: $(<span style="color: #006080">&quot;#RegisterErrors&quot;</span>),</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>     rules: {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>             FirstNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>             LastNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>             EmailEdit: { required: <span style="color: #0000ff">true</span>, email: <span style="color: #0000ff">true</span> }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span>         },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span>         messages: {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span>             FirstNameEdit: <span style="color: #006080">&quot;First name is required&quot;</span>,</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span>             LastNameEdit: <span style="color: #006080">&quot;Last name is required&quot;</span>,</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12">  12:</span>             EmailEdit: <span style="color: #006080">&quot;Valid email address is required&quot;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13">  13:</span>         }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14">  14:</span>     });</pre>
<!--CRLF--></div>
</div>

<p></p>

<p>Which then gives better messages.</p>

<h2>For next time</h2>

<p>Ok, this is not all the JQuery Validation library can do, there is a lot more, but this is enough for now.&#160; Next post will show how to validate fields using web service results, and various callbacks that can be used to customize the library.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/09/27/playing-with-jquery-validation-library/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>FireFox+Firebug vs IE8 Developer Toolbar</title>
		<link>http://elegantcode.com/2010/01/29/jetbrains-web-ide/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=jetbrains-web-ide</link>
		<comments>http://elegantcode.com/2010/01/29/jetbrains-web-ide/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 21:03:26 +0000</pubDate>
		<dc:creator>Jan Van Ryswyck</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/01/29/jetbrains-web-ide/</guid>
		<description><![CDATA[As I already mentioned in a previous blog post, I’m kind of (re-)learning HTML and CSS. The best way for me to pick things up again is by getting my hands dirty and work myself through a simple example. So I decided to work on some sort of prototype of a web application without using [...]]]></description>
			<content:encoded><![CDATA[<p>As I already mentioned in a <a href="http://elegantcode.com/2010/01/26/css-basics-the-box-model/">previous blog post</a>, I’m kind of (re-)learning HTML and CSS. The best way for me to pick things up again is by getting my hands dirty and work myself through a simple example. So I decided to work on some sort of prototype of a web application without using any web framework like ASP.NET MVC, Fubu MVC, Ruby on Rails, etc. … Just plain old HTML and CSS, like the Internet gods intended. I also didn’t want to suck all the fun out of it either, so I decided to use <a href="http://www.jetbrains.com/webide/index.html">Web IDE</a> from <a href="http://www.jetbrains.com/index.html">JetBrains</a> as my IDE for churning out this prototype. </p>  <p>I must say that I was pleasantly surprised by some of the features that this IDE has to offer. The first and most obvious one is probably intellisense that just works as expected.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/01/image9.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/01/image_thumb9.png" width="553" height="385" /></a> </p>  <p>Also notice the on-the-fly code inspection (colored marker bar on the right) that should be familiar when you’re a Resharper addict like me. Web IDE provides W3C XHTML/CSS validation while working in the editor which is really useful. </p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/01/image10.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/01/image_thumb10.png" width="548" height="381" /></a> </p>  <p>Being the uncertain type, it was also nice to see all the familiar refactoring features from Resharper being available as well. Renaming a class or id is just a breeze. All the corresponding HTML or CSS files are consistently updated.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/01/image11.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/01/image_thumb11.png" width="546" height="382" /></a> </p>  <p>Navigation is there as well (CTRL-N and CTRL-SHIFT-N).</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/01/image12.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/01/image_thumb12.png" width="543" height="378" /></a> </p>  <p>This looks just like <a href="http://www.jetbrains.com/resharper/index.html">Resharper</a> for web developers, but there’s more. At first, I had all the HTML and CSS files including all the image file in the root folder of the project. I wanted to divide and conquer by putting the images and CSS files into their own separate folder. As I prepared myself to change all the references in the HTML files, Web IDE did that all for me when I dragged the files to their final destination. Now I didn’t had to go over all the HTML files and manually change the links. How cool is that!</p>  <p>Web IDE also provides source-control integration Subversion, Git, Perforce, etc … and that’s just the tip of the iceberg. While working on the prototype of the web application, I mostly focused on the layout and not so much on the behavior so I didn’t use much of the JavaScript capabilities. But I was told that it is comparable with the JavaScript features in <a href="http://www.jetbrains.com/ruby/index.html">RubyMine</a> as described by Peter in <a href="http://peter.worksontheweb.net/post/An-alternative-to-editing-JavaScript-in-Visual-Studio-RubyMine.aspx">this blog post</a>. This is something that I’m going to explore when I start learning more about JavaScript :-). </p>  <p>Although being the first version and still in beta, the IDE seems pretty stable and I couldn’t notice any performance hiccups so far (which <a href="http://davybrion.com/blog/2010/01/i-still-have-low-expectations-for-visual-studio-2010/">cannot be said for all IDE’s</a> these days). </p>  <p>I do hope that there will be some support for ASP.NET or other view engines like <a href="http://sparkviewengine.com/">Spark</a>, <a href="http://nvelocity.sourceforge.net/">NVelocity</a>, etc. … in future versions. In fact, I still silently wish that JetBrains would come up with an IDE for .NET. Being realistic about it, I don’t have high hopes for something like that coming out but it would totally rock if they decided to build one. Sweet dreams :-)</p>  <p>Bottom line, when you’re doing web development in Visual Studio, make sure to also check out Web IDE. It will probably help you to become more productive along the way.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/01/29/jetbrains-web-ide/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Elegant Code &#187; html</title>
	<atom:link href="http://elegantcode.com/category/html/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com</link>
	<description></description>
	<lastBuildDate>Tue, 15 May 2012 10:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>The Web is Not Platform Independent</title>
		<link>http://elegantcode.com/2010/08/22/the-web-is-not-platform-independent/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-web-is-not-platform-independent</link>
		<comments>http://elegantcode.com/2010/08/22/the-web-is-not-platform-independent/#comments</comments>
		<pubDate>Sun, 22 Aug 2010 20:16:32 +0000</pubDate>
		<dc:creator>John Sonmez</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/08/22/the-web-is-not-platform-independent/</guid>
		<description><![CDATA[There was a time when you wrote a web site and you targeted IE6. That time has long passed. When you really only had to target IE6, you could pretend the web was platform independent. The truth is now the web is neither, nor will ever be platform independent.&#160; It’s just an illusion based on [...]]]></description>
			<content:encoded><![CDATA[<p>There was a time when you wrote a web site and you targeted IE6.</p>  <p>That time has long passed.</p>  <p>When you really only had to target IE6, you could pretend the web was platform independent.</p>  <p>The truth is now the web is neither, nor will ever be platform independent.&#160; It’s just an illusion based on the simple notion that browsers basically just render HTML.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/08/pegi.jpg"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="pegi" border="0" alt="pegi" src="http://elegantcode.com/wp-content/uploads/2010/08/pegi_thumb.jpg" width="438" height="517" /></a></p>  <h2>How many platforms are there then?</h2>  <p>This is a surprisingly difficult question to answer.</p>  <p>Back before the web really took off there were basically 3 platforms to develop an app for: Windows; Unix/Linux; and Mac.</p>  <p>When we answer this question for the web, really we have to look at browsers as if they are the operating system.&#160; Since the same browser exists on multiple base OS’s but could be different, we have to count each combination of browser and OS as a potentially separate version.</p>  <p>Windows: IE6, IE7, IE8, IE9 (beta), Firefox, Chrome, Safari</p>  <p>OSX: IE, Firefox, Safari (more?)</p>  <p>Linux: Firefox, Chrome</p>  <p>Android: Webkit</p>  <p>iPad, iPhone: Safari</p>  <p>I don’t have nearly every combination listed, but this is what I would consider a good coverage for any kind of public facing website.</p>  <p>Oh, don’t forget to cross this again with localization and globalization, because you might have a localization problem that only happens in a certain language in a certain browser on a certain OS.</p>  <h2>Not just rendering level differences</h2>  <p>It is also very interesting to consider that a web developer now has to consider how their site will not just render, but be used on a mobile platform.&#160; </p>  <p>Consider how Google released an iPad version of Gmail.&#160; And although, you may not really care if your site works on an iPhone or an Android phone, you probably should start caring about how it works on tablets like the iPad, because that market is only growing. </p>  <p><strong>If you have a website that doesn’t work on someone’s iPad when they are shopping online, do you think they will get up, go turn on the computer, and go to your site to make the purchase or they will buy from a different site with a few touches?</strong></p>  <p>With a phone size resolution, the considerations are even more important.</p>  <h2>Tools help me make the web platform independent</h2>  <p>No tool exists right now that can handle the non-technical aspects of platform independence for your web application, but let us imagine for a second that a library like JQuery really made your javascript platform independent.</p>  <p>If we were to hold onto that shaky assumption, we would need to make sure that we never wrote javascript that wasn’t written through the JQuery API.&#160; (Which happens to be an extremely leaky abstraction over javascript, CSS, and the DOM.) We would still have to make sure our HTML and CSS tags were platform independent.</p>  <p>So even if we could get parts of our development to be mostly platform independent, we would still need to test on all of the major platforms, because we could not rely on the platform independence.</p>  <p>Now, don’t get me wrong here.&#160; I love JQuery.&#160; It makes the job of a web developer so much easier.&#160; But, there is an important distinction.&#160; <strong>APIs and libraries like JQuery make it easier to write platform independent web code, but they don’t make our code platform independent.</strong></p>  <h2>What does all this mean?</h2>  <p>We’ve gotten to the point where the most platform independent technology you can use is either Flash or Silverlight.</p>  <p>I’m not sure if this is the future of development, but it very well might be.</p>  <p>One important point to draw from this realization is that we shouldn’t necessarily choose to make our application a web application, because we need it to be platform independent.&#160; It seems like about 5 years ago, the web became the default choice, because it was better to have platform independence than a rich UI.</p>  <p>Hopefully, for the sake of web developers some of these paths die off or converge, or that standards compliance becomes so good that you could really write code for one browser and expect it to work on all the others.</p>  <h6>As always, you can subscribe to this <a href="http://feeds2.feedburner.com/ElegantCode">RSS feed</a> to follow my posts on elegant code.&#160; Feel free to check out my main personal blog at <a href="http://simpleprogrammer.com">http://simpleprogrammer.com</a>, which has a wider range of posts, updated 2-3 times a week.&#160; Also, you can follow me on twitter <a href="http://twitter.com/jsonmez">here</a>.</h6>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/08/22/the-web-is-not-platform-independent/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Your JavaScript goes WHERE?</title>
		<link>http://elegantcode.com/2010/03/30/your-javascript-goes-where/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=your-javascript-goes-where</link>
		<comments>http://elegantcode.com/2010/03/30/your-javascript-goes-where/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 03:35:37 +0000</pubDate>
		<dc:creator>Chris Brandsma</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/03/30/your-javascript-goes-where/</guid>
		<description><![CDATA[Let me start by saying that I was not trying to be controversial.  I was at Boise Code Camp giving a session about Asp.Net MVC, and I happened to mention that JavaScript was supposed to go at the bottom of your page.  Plus, I said this in a “of course you all know this already” [...]]]></description>
			<content:encoded><![CDATA[Let me start by saying that I was not trying to be controversial.  I was at Boise Code Camp giving a session about Asp.Net MVC, and I happened to mention that JavaScript was supposed to go at the bottom of your page.  Plus, I said this in a “of course you all know this already” type of voice, thinking this needed no further explanation.

Then the hands started raising.  Quickly, I might add.  I had to explain myself.  Yes, JavaScript goes at the bottom of your page.  Yes, I realize that we were all taught, back in the day, that JavaScript’s true home was in the &lt;head&gt; element.  In fact, <a href="http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery">many sample pages still show JavaScript at the top</a>.  But we probably learned that ten years ago, you have to think a few things have changed…except IE6 – that sucker is going to live forever!  Anyway, I’m not the type that like to stand up in a crowd and say “everything you, and everyone you know, is doing is wrong” (I’m not that smart).  And if I do, I want to come with some substantial proof.

To start, <a href="http://www.w3.org/TR/REC-html40/interact/scripts.html#h-18.2.1">where does the w3c say the SCRIPT element is supposed to go?</a>  If you read the document in the link, SCRIPT can live in either the HEAD or the BODY elements. So technically, both places are legal.  I am stating this so that no one come back and tells me I’m breaking any fundamental web rules.  If the w3c says it is ok, then it is ok darn it.
<h2>But why the bottom of the page? </h2>
That one is slightly harder to explain.  But here are the basics:  when a browser loads a document there are only so many thread for processing the document and download all the other crap that you put on the page <a href="http://theoatmeal.com/comics/design_hell">so it pops</a> (so, images and css, not to mention the bagillion font tags that Word likes to put in html).  There is also an unwritten rule that JavaScript should enhance the page after it is loaded.  So any time the browser spends parsing JavaScript is time it could be using to make the page look right.  Also, with some browsers, when the browser is loading JavaScript, ALL OTHER ACTIVITY STOPS.  Nothing else is downloaded, the browser is at a standstill until all the script is parsed – and <a href="http://ejohn.org/blog/javascript-performance-rundown/">you know how fast IE is at JavaScript.</a>

Lets be clear about this “rule”.  <a href="http://developer.yahoo.com/performance/rules.html#js_bottom">I did not make this up.</a>  But there are other ways around the performance penalty, you can also <a href="http://code.google.com/speed/page-speed/docs/payload.html#DeferLoadingJS">defer load</a> your JavaScript.  Also, putting all of the JavaScript into a single, external file is a great idea.  With a external file you get the added benefit of the JavaScript file being cached by the browser (Note: great for the user – pain for your tester.  Repeat after me, “CLEAR YOUR CACHE” often when testing).

OK, so let us review.

<a href="http://elegantcode.com/wp-content/uploads/2010/03/image17.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" src="http://elegantcode.com/wp-content/uploads/2010/03/image_thumb17.png" border="0" alt="image" width="823" height="594" /></a>
<h2>But how bad is this?</h2>
That is a fair question as well.  Truthfully, it depends.  I know that is my stock answer, but I’m talking about how much this will affect the user.  It could be nothing.  But if you have a lot of JavaScript on the page, it could be significant.   Potentially it could be as annoying as a blink tag.  Even worse it might be on par with ESPN and their auto-playing videos.   But, if we are talking about 10-20 lines of script, there could be no change at all in render time. I will say this, by moving the script to the bottom of the page I have taken pages that were not usable for 10 seconds, improved it to moments (the page had a LOT of JavaScript…and it was a very noble cause).
<h2>What else should I be doing that I’m not?</h2>
This one is easy.  Run all of your pages through <a href="http://developer.yahoo.com/yslow/">YSlow</a> and <a href="http://code.google.com/speed/page-speed/">PageSpeed</a> (you need FireFox and <a href="http://getfirebug.com/">Firebug</a> installed for this) and find out.  Also, you don’t have to be perfect as far as these tools are concerned.  Some of the rule are probably not practical either (the “You should be using a CDN for images” rule comes to mind).  But it is good to know where you can improve.  PageSpeed has a number of really nice tools as well.  It will return you properly sized images, and compressed CSS and JavaScript if you ask it.]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/03/30/your-javascript-goes-where/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Introducing oEmbed</title>
		<link>http://elegantcode.com/2010/03/05/introducing-oembed/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=introducing-oembed</link>
		<comments>http://elegantcode.com/2010/03/05/introducing-oembed/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 06:12:08 +0000</pubDate>
		<dc:creator>cory.isakson</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[WebServices]]></category>
		<category><![CDATA[oembed]]></category>

		<guid isPermaLink="false">http://elegantcode.com/?p=3325</guid>
		<description><![CDATA[Gadgets, widgets, flash, ActiveX, Silverlight, json, xml With all of the competing technologies for content embedding and resource sharing on the web it can be difficult to determine which options to use.  Have you ever wished that you could embed YouTube videos and Flickr photos into your site just by knowing the consumer friendly URLi’s [...]]]></description>
			<content:encoded><![CDATA[Gadgets, widgets, flash, ActiveX, Silverlight, json, xml

With all of the competing technologies for content embedding and resource sharing on the web it can be difficult to determine which options to use.  Have you ever wished that you could embed YouTube videos and Flickr photos into your site just by knowing the consumer friendly URLi’s to them?  That is exactly what <a href="http://oembed.com">oEmbed</a> provides.  I would like to introduce you to the basics of the specification.  I hope the simplicity encourages you to support it as a provider and as a consumer when embedding resources from other providers.  Many popular sites already support it!
<blockquote>oEmbed is a format for allowing an embedded representation of a URL on third party sites. The simple API allows a website to display embedded content (such as photos or videos) when a user posts a link to that resource, without having to parse the resource directly.</blockquote>
Lets take a look at each side of a provider and consumer scenario to illustrate how oEmbed provides and elegant solution for each.
<blockquote>Providers must specify one or more URL scheme and API endpoint pairs. The URL scheme describes which URLs provided by the service may have an embedded representation.</blockquote>
The publisher must determine what scheme(s) they support in very basic format.  Typically the scheme matches URLs that consumers would browse resources at normally.  The YouTube API, for example, supports URLs matching the scheme <a href="http://*.youtube.com/watch">http://*.youtube.com/watch</a>*

The API endpoint is simply an http URL at which consumers request oEmbed representations of the resources you provide.  Most of the current providers offer API endpoints with obvious URL’s like <a title="http://www.youtube.com/oembed" href="http://www.youtube.com/oembed">http://www.youtube.com/oembed</a> and <a title="http://www.flickr.com/services/oembed/" href="http://www.flickr.com/services/oembed/">http://www.flickr.com/services/oembed/</a>.

Once you have the endpoint you just need to host a service there that accepts 4 specific query parameters:

url : The urlencoded url that matches a supported provider defined scheme.
maxwidth : (optional) The maximum width you want for embedding the resource.
maxheight : (optional) The maximum height you want for embedding the resource.
format: (optional) xml or json are the possible values that determine the consumers desired response Content-Type.
<blockquote>Requests sent to the API endpoint must be HTTP GET requests, with all arguments sent as query parameters. All arguments must be urlencoded (as per RFC 1738).</blockquote>
oEmbed consumers make requests for the oEmbed representation of a resource by sending a basic GET request to an API endpoint with url query parameters and any optional parameters they choose.

A request to <a title="http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3D6lbDyXu7gUQ" href="http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3D6lbDyXu7gUQ">http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3D6lbDyXu7gUQ</a> results in a json response:
<pre>{
"provider_url": "http://www.youtube.com/",
"title": "Insert a YouTube Video With oEmbed Wordpress 2.9",
"html": "&lt;object width=\"480\" height=\"295\"&gt;
    &lt;param name=\"movie\" value=\"http://www.youtube.com/v/6lbDyXu7gUQ&amp;fs=1\"&gt;&lt;/param&gt;
    &lt;param name=\"allowFullScreen\" value=\"true\"&gt;&lt;/param&gt;
    &lt;param name=\"allowscriptaccess\" value=\"always\"&gt;&lt;/param&gt;
    &lt;embed src=\"http://www.youtube.com/v/6lbDyXu7gUQ&amp;fs=1\" type=\"application/x-shockwave-flash\"
        width=\"480\" height=\"295\" allowscriptaccess=\"always\" allowfullscreen=\"true\"&gt;&lt;/embed&gt;&lt;/object&gt;",
"author_name": "adriarichards", "height": 295, "width": 480, "version": "1.0",
"author_url": "http://www.youtube.com/user/adriarichards",
"provider_name": "YouTube",
"type": "video"
}</pre>
Note the html property.  It contains everything you need to embed the video.  If this installation of WordPress was running version 2.9 I could paste a YouTube URL here and it would automatically get embeded as described in the video <a href="http://www.youtube.com/watch?v=6lbDyXu7gUQ">Insert a YouTube Video With oEmbed Wordpress 2.9</a>

oEmbed supports 4 result types including video, photo, link and rich.  The rich type allows for just about any html to be returned and thus embedded.
<blockquote>Consumers may wish to load the HTML in an off-domain iframe to avoid XSS vulnerabilities.</blockquote>
To learn more and see a list of some current providers check it out at:

<a title="http://oembed.com/" href="http://oembed.com/">http://oembed.com/</a>

And for a few more implementations check out <a title="http://oohembed.com/" href="http://oohembed.com/">http://oohembed.com/</a>

I look forward to hearing how you end up using oEmbed!]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/03/05/introducing-oembed/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JetBrains Web IDE</title>
		<link>http://elegantcode.com/2010/01/29/jetbrains-web-ide/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=jetbrains-web-ide</link>
		<comments>http://elegantcode.com/2010/01/29/jetbrains-web-ide/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 21:03:26 +0000</pubDate>
		<dc:creator>Jan Van Ryswyck</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/01/29/jetbrains-web-ide/</guid>
		<description><![CDATA[As I already mentioned in a previous blog post, I’m kind of (re-)learning HTML and CSS. The best way for me to pick things up again is by getting my hands dirty and work myself through a simple example. So I decided to work on some sort of prototype of a web application without using [...]]]></description>
			<content:encoded><![CDATA[<p>As I already mentioned in a <a href="http://elegantcode.com/2010/01/26/css-basics-the-box-model/">previous blog post</a>, I’m kind of (re-)learning HTML and CSS. The best way for me to pick things up again is by getting my hands dirty and work myself through a simple example. So I decided to work on some sort of prototype of a web application without using any web framework like ASP.NET MVC, Fubu MVC, Ruby on Rails, etc. … Just plain old HTML and CSS, like the Internet gods intended. I also didn’t want to suck all the fun out of it either, so I decided to use <a href="http://www.jetbrains.com/webide/index.html">Web IDE</a> from <a href="http://www.jetbrains.com/index.html">JetBrains</a> as my IDE for churning out this prototype. </p>  <p>I must say that I was pleasantly surprised by some of the features that this IDE has to offer. The first and most obvious one is probably intellisense that just works as expected.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/01/image9.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/01/image_thumb9.png" width="553" height="385" /></a> </p>  <p>Also notice the on-the-fly code inspection (colored marker bar on the right) that should be familiar when you’re a Resharper addict like me. Web IDE provides W3C XHTML/CSS validation while working in the editor which is really useful. </p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/01/image10.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/01/image_thumb10.png" width="548" height="381" /></a> </p>  <p>Being the uncertain type, it was also nice to see all the familiar refactoring features from Resharper being available as well. Renaming a class or id is just a breeze. All the corresponding HTML or CSS files are consistently updated.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/01/image11.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/01/image_thumb11.png" width="546" height="382" /></a> </p>  <p>Navigation is there as well (CTRL-N and CTRL-SHIFT-N).</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/01/image12.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/01/image_thumb12.png" width="543" height="378" /></a> </p>  <p>This looks just like <a href="http://www.jetbrains.com/resharper/index.html">Resharper</a> for web developers, but there’s more. At first, I had all the HTML and CSS files including all the image file in the root folder of the project. I wanted to divide and conquer by putting the images and CSS files into their own separate folder. As I prepared myself to change all the references in the HTML files, Web IDE did that all for me when I dragged the files to their final destination. Now I didn’t had to go over all the HTML files and manually change the links. How cool is that!</p>  <p>Web IDE also provides source-control integration Subversion, Git, Perforce, etc … and that’s just the tip of the iceberg. While working on the prototype of the web application, I mostly focused on the layout and not so much on the behavior so I didn’t use much of the JavaScript capabilities. But I was told that it is comparable with the JavaScript features in <a href="http://www.jetbrains.com/ruby/index.html">RubyMine</a> as described by Peter in <a href="http://peter.worksontheweb.net/post/An-alternative-to-editing-JavaScript-in-Visual-Studio-RubyMine.aspx">this blog post</a>. This is something that I’m going to explore when I start learning more about JavaScript :-). </p>  <p>Although being the first version and still in beta, the IDE seems pretty stable and I couldn’t notice any performance hiccups so far (which <a href="http://davybrion.com/blog/2010/01/i-still-have-low-expectations-for-visual-studio-2010/">cannot be said for all IDE’s</a> these days). </p>  <p>I do hope that there will be some support for ASP.NET or other view engines like <a href="http://sparkviewengine.com/">Spark</a>, <a href="http://nvelocity.sourceforge.net/">NVelocity</a>, etc. … in future versions. In fact, I still silently wish that JetBrains would come up with an IDE for .NET. Being realistic about it, I don’t have high hopes for something like that coming out but it would totally rock if they decided to build one. Sweet dreams :-)</p>  <p>Bottom line, when you’re doing web development in Visual Studio, make sure to also check out Web IDE. It will probably help you to become more productive along the way.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/01/29/jetbrains-web-ide/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Playing with JQuery Validation library</title>
		<link>http://elegantcode.com/2009/09/27/playing-with-jquery-validation-library/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=playing-with-jquery-validation-library</link>
		<comments>http://elegantcode.com/2009/09/27/playing-with-jquery-validation-library/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 04:21:16 +0000</pubDate>
		<dc:creator>Chris Brandsma</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JQuery]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/09/27/playing-with-jquery-validation-library/</guid>
		<description><![CDATA[New job (2 weeks in), new responsibilities, new tools to play with.&#160; Amazingly (for me), one of the new tools is the JQuery Validation Library.&#160; My diving into this also coincides with ScottGu’s announcement that Microsoft is creating their own CDN for JQuery and JQuery Validation.&#160; Bad news is that this means I’m behind.&#160; That [...]]]></description>
			<content:encoded><![CDATA[<p>New job (2 weeks in), new responsibilities, new tools to play with.&#160; Amazingly (for me), one of the new tools is the <a href="http://docs.jquery.com/Plugins/Validation">JQuery Validation Library</a>.&#160; My diving into this also coincides with ScottGu’s announcement that Microsoft is creating their own <a href="http://weblogs.asp.net/scottgu/archive/2009/09/15/announcing-the-microsoft-ajax-cdn.aspx">CDN for JQuery and JQuery Validation</a>.&#160; </p>  <p>Bad news is that this means I’m behind.&#160; That sucks.&#160; I was using JQuery MONTHS before Microsoft officially started supporting it (at least 6 months – but I’m too lazy to look it up).&#160; Anyway, now you can use Microsoft’s bandwidth to get JQuery to your customer’s browser with this line:</p>  <p>&lt;script src=&quot;http://ajax.microsoft.com/ajax/jquery/jquery-1.3.2.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</p>  <p>And you can add the JQuery Validation library like this: </p>  <p>&lt;script src=&quot;http://ajax.microsoft.com/ajax/jquery.validate/1.5.5/jquery.validate.js&quot; type=”text/javascript”&gt;&lt;/script&gt;</p>  <p>Note: see those end tags, great annoyance of my life, but you have to have them, you can’t do &lt;script src=”http://…” /&gt;.&#160; That sucks, but I’m learning to live with it.</p>  <p>Anyway, back to validation.</p>  <p>The more I play with this library, the more I like it.&#160; It is very configurable, easily style-able, the documentation isn’t half bad, and the code is readable.</p>  <h2>Getting Started with JQuery Validation:</h2>  <p><strong>The JavaScript Way:</strong>&#160; OK, assuming you have JQuery and the JQuery Validation library included, lets start with a simple customer form:</p>  <p></p>  <div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">   <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">     <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">form</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;CustomerForm&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;firstNameEdit&quot;</span><span style="color: #0000ff">&gt;</span>First Name:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;firstNameEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;LastNameEdit&quot;</span><span style="color: #0000ff">&gt;</span>Last Name:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;LastNameEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;EmailEdit&quot;</span><span style="color: #0000ff">&gt;</span>Email:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12">  12:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;EmailEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13">  13:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14">  14:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum15">  15:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">button</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;submit&quot;</span><span style="color: #0000ff">&gt;</span>Submit<span style="color: #0000ff">&lt;/</span><span style="color: #800000">button</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum16">  16:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum17">  17:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">form</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF--></div>
</div>

<p>Nothing special there.&#160; Just a bunch of inputs and labels.&#160; If you hit the submit button, a postback is fired and the data is sent back to the server.</p>

<p>But, business requirements dictate that all fields are required.&#160; Simple enough, using JQuery the hookup looks like this:</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> $(<span style="color: #006080">&quot;#CustomerForm&quot;</span>).validate({</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span>     rules: {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span>       FirstNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>       LastNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>       EmailEdit: { required: <span style="color: #0000ff">true</span>, email:<span style="color: #0000ff">true</span> }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>     }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span> });</pre>
<!--CRLF--></div>
</div>

<p>OK, the first name, last name, and email will now be required.&#160; I also threw a little extra in there: email validation.&#160; If you submit the form like this will be added after any of the required fields:</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> &lt;label <span style="color: #0000ff">class</span>=<span style="color: #006080">&quot;error&quot;</span> <span style="color: #0000ff">for</span>=<span style="color: #006080">&quot;FirstName&quot;</span> generated=<span style="color: #006080">&quot;true&quot;</span>&gt;This field <span style="color: #0000ff">is</span> required.&lt;/label&gt;</pre>
<!--CRLF--></div>
</div>

<p>Key part there is the ‘error’ css class which is great for styling the messages.&#160; So you can use the ‘label.error’ in your css class.</p>

<h2>Another way</h2>

<p>You can also use css classes to setup which fields are required.&#160; It is a nice and simple way to hook everything up, but it is not as easily configurable (as we will see in a moment):</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">form</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;CustomerForm&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;FirstNameEdit&quot;</span><span style="color: #0000ff">&gt;</span>First Name:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;FirstNameEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot;</span> class=”required”<span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;LastNameEdit&quot;</span><span style="color: #0000ff">&gt;</span>Last Name:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;LastNameEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot; class=”required”</span> <span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;EmailEdit&quot;</span><span style="color: #0000ff">&gt;</span>Email:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12">  12:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;EmailEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot;</span> class=”required email”<span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13">  13:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14">  14:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum15">  15:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">button</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;submit&quot;</span><span style="color: #0000ff">&gt;</span>Submit<span style="color: #0000ff">&lt;/</span><span style="color: #800000">button</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum16">  16:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum17">  17:</span> <span style="color: #0000ff">&lt;/form</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF--></div>
</div>

<p>The the Javascript is actually much simpler:</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> $(<span style="color: #006080">&quot;CustomerForm&quot;</span>).validate();</pre>
<!--CRLF--></div>
</div>

<p>And you will get the same results.&#160; But, the rest of the samples will use the prior code setup.&#160; Also note: you can mix and match the css style with the JavaScript style.</p>

<h2>Moving the message</h2>

<p>Next problem you might encounter is you want to move the messages to another part of the screen.&#160; Remember, default behavior is the messages go next to the control.</p>

<p>To solve this we will add a div to the page:</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 31px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">div</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;RegisterErrors&quot;</span> <span style="color: #ff0000">style</span><span style="color: #0000ff">=&quot;display:none&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF--></div>
</div>

<p>I can setup the Validation library to use this by going back to the validate method and adding errorLabelContainer directive.</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> $(“#CustomerForm”).validate({</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> <strong>errorLabelContainer: $(<span style="color: #006080">&quot;#RegisterErrors&quot;</span>),</strong></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> rules: {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>         FirstNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>         LastNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>         EmailEdit: { required: <span style="color: #0000ff">true</span>, email: <span style="color: #0000ff">true</span> }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>     }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span> });</pre>
<!--CRLF--></div>
</div>

<p>Now this is great, but there is still a problem.&#160; Each of the messages will be “This field is required”.&#160; That doesn’t say which field is the problem.&#160; Lets add custom messages for each field.</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> </pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span>     $(<span style="color: #006080">&quot;#CustomerForm&quot;</span>).validate({</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span>     errorLabelContainer: $(<span style="color: #006080">&quot;#RegisterErrors&quot;</span>),</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>     rules: {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>             FirstNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>             LastNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>             EmailEdit: { required: <span style="color: #0000ff">true</span>, email: <span style="color: #0000ff">true</span> }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span>         },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span>         messages: {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span>             FirstNameEdit: <span style="color: #006080">&quot;First name is required&quot;</span>,</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span>             LastNameEdit: <span style="color: #006080">&quot;Last name is required&quot;</span>,</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12">  12:</span>             EmailEdit: <span style="color: #006080">&quot;Valid email address is required&quot;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13">  13:</span>         }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14">  14:</span>     });</pre>
<!--CRLF--></div>
</div>

<p></p>

<p>Which then gives better messages.</p>

<h2>For next time</h2>

<p>Ok, this is not all the JQuery Validation library can do, there is a lot more, but this is enough for now.&#160; Next post will show how to validate fields using web service results, and various callbacks that can be used to customize the library.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/09/27/playing-with-jquery-validation-library/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>FireFox+Firebug vs IE8 Developer Toolbar</title>
		<link>http://elegantcode.com/2009/09/27/playing-with-jquery-validation-library/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=playing-with-jquery-validation-library</link>
		<comments>http://elegantcode.com/2009/09/27/playing-with-jquery-validation-library/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 04:21:16 +0000</pubDate>
		<dc:creator>Chris Brandsma</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JQuery]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/09/27/playing-with-jquery-validation-library/</guid>
		<description><![CDATA[New job (2 weeks in), new responsibilities, new tools to play with.&#160; Amazingly (for me), one of the new tools is the JQuery Validation Library.&#160; My diving into this also coincides with ScottGu’s announcement that Microsoft is creating their own CDN for JQuery and JQuery Validation.&#160; Bad news is that this means I’m behind.&#160; That [...]]]></description>
			<content:encoded><![CDATA[<p>New job (2 weeks in), new responsibilities, new tools to play with.&#160; Amazingly (for me), one of the new tools is the <a href="http://docs.jquery.com/Plugins/Validation">JQuery Validation Library</a>.&#160; My diving into this also coincides with ScottGu’s announcement that Microsoft is creating their own <a href="http://weblogs.asp.net/scottgu/archive/2009/09/15/announcing-the-microsoft-ajax-cdn.aspx">CDN for JQuery and JQuery Validation</a>.&#160; </p>  <p>Bad news is that this means I’m behind.&#160; That sucks.&#160; I was using JQuery MONTHS before Microsoft officially started supporting it (at least 6 months – but I’m too lazy to look it up).&#160; Anyway, now you can use Microsoft’s bandwidth to get JQuery to your customer’s browser with this line:</p>  <p>&lt;script src=&quot;http://ajax.microsoft.com/ajax/jquery/jquery-1.3.2.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</p>  <p>And you can add the JQuery Validation library like this: </p>  <p>&lt;script src=&quot;http://ajax.microsoft.com/ajax/jquery.validate/1.5.5/jquery.validate.js&quot; type=”text/javascript”&gt;&lt;/script&gt;</p>  <p>Note: see those end tags, great annoyance of my life, but you have to have them, you can’t do &lt;script src=”http://…” /&gt;.&#160; That sucks, but I’m learning to live with it.</p>  <p>Anyway, back to validation.</p>  <p>The more I play with this library, the more I like it.&#160; It is very configurable, easily style-able, the documentation isn’t half bad, and the code is readable.</p>  <h2>Getting Started with JQuery Validation:</h2>  <p><strong>The JavaScript Way:</strong>&#160; OK, assuming you have JQuery and the JQuery Validation library included, lets start with a simple customer form:</p>  <p></p>  <div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">   <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">     <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">form</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;CustomerForm&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;firstNameEdit&quot;</span><span style="color: #0000ff">&gt;</span>First Name:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;firstNameEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;LastNameEdit&quot;</span><span style="color: #0000ff">&gt;</span>Last Name:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;LastNameEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;EmailEdit&quot;</span><span style="color: #0000ff">&gt;</span>Email:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12">  12:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;EmailEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13">  13:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14">  14:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum15">  15:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">button</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;submit&quot;</span><span style="color: #0000ff">&gt;</span>Submit<span style="color: #0000ff">&lt;/</span><span style="color: #800000">button</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum16">  16:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum17">  17:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">form</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF--></div>
</div>

<p>Nothing special there.&#160; Just a bunch of inputs and labels.&#160; If you hit the submit button, a postback is fired and the data is sent back to the server.</p>

<p>But, business requirements dictate that all fields are required.&#160; Simple enough, using JQuery the hookup looks like this:</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> $(<span style="color: #006080">&quot;#CustomerForm&quot;</span>).validate({</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span>     rules: {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span>       FirstNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>       LastNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>       EmailEdit: { required: <span style="color: #0000ff">true</span>, email:<span style="color: #0000ff">true</span> }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>     }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span> });</pre>
<!--CRLF--></div>
</div>

<p>OK, the first name, last name, and email will now be required.&#160; I also threw a little extra in there: email validation.&#160; If you submit the form like this will be added after any of the required fields:</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> &lt;label <span style="color: #0000ff">class</span>=<span style="color: #006080">&quot;error&quot;</span> <span style="color: #0000ff">for</span>=<span style="color: #006080">&quot;FirstName&quot;</span> generated=<span style="color: #006080">&quot;true&quot;</span>&gt;This field <span style="color: #0000ff">is</span> required.&lt;/label&gt;</pre>
<!--CRLF--></div>
</div>

<p>Key part there is the ‘error’ css class which is great for styling the messages.&#160; So you can use the ‘label.error’ in your css class.</p>

<h2>Another way</h2>

<p>You can also use css classes to setup which fields are required.&#160; It is a nice and simple way to hook everything up, but it is not as easily configurable (as we will see in a moment):</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">form</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;CustomerForm&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;FirstNameEdit&quot;</span><span style="color: #0000ff">&gt;</span>First Name:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;FirstNameEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot;</span> class=”required”<span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;LastNameEdit&quot;</span><span style="color: #0000ff">&gt;</span>Last Name:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;LastNameEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot; class=”required”</span> <span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;EmailEdit&quot;</span><span style="color: #0000ff">&gt;</span>Email:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12">  12:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;EmailEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot;</span> class=”required email”<span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13">  13:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14">  14:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum15">  15:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">button</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;submit&quot;</span><span style="color: #0000ff">&gt;</span>Submit<span style="color: #0000ff">&lt;/</span><span style="color: #800000">button</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum16">  16:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum17">  17:</span> <span style="color: #0000ff">&lt;/form</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF--></div>
</div>

<p>The the Javascript is actually much simpler:</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> $(<span style="color: #006080">&quot;CustomerForm&quot;</span>).validate();</pre>
<!--CRLF--></div>
</div>

<p>And you will get the same results.&#160; But, the rest of the samples will use the prior code setup.&#160; Also note: you can mix and match the css style with the JavaScript style.</p>

<h2>Moving the message</h2>

<p>Next problem you might encounter is you want to move the messages to another part of the screen.&#160; Remember, default behavior is the messages go next to the control.</p>

<p>To solve this we will add a div to the page:</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 31px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">div</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;RegisterErrors&quot;</span> <span style="color: #ff0000">style</span><span style="color: #0000ff">=&quot;display:none&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF--></div>
</div>

<p>I can setup the Validation library to use this by going back to the validate method and adding errorLabelContainer directive.</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> $(“#CustomerForm”).validate({</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> <strong>errorLabelContainer: $(<span style="color: #006080">&quot;#RegisterErrors&quot;</span>),</strong></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> rules: {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>         FirstNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>         LastNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>         EmailEdit: { required: <span style="color: #0000ff">true</span>, email: <span style="color: #0000ff">true</span> }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>     }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span> });</pre>
<!--CRLF--></div>
</div>

<p>Now this is great, but there is still a problem.&#160; Each of the messages will be “This field is required”.&#160; That doesn’t say which field is the problem.&#160; Lets add custom messages for each field.</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> </pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span>     $(<span style="color: #006080">&quot;#CustomerForm&quot;</span>).validate({</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span>     errorLabelContainer: $(<span style="color: #006080">&quot;#RegisterErrors&quot;</span>),</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>     rules: {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>             FirstNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>             LastNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>             EmailEdit: { required: <span style="color: #0000ff">true</span>, email: <span style="color: #0000ff">true</span> }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span>         },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span>         messages: {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span>             FirstNameEdit: <span style="color: #006080">&quot;First name is required&quot;</span>,</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span>             LastNameEdit: <span style="color: #006080">&quot;Last name is required&quot;</span>,</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12">  12:</span>             EmailEdit: <span style="color: #006080">&quot;Valid email address is required&quot;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13">  13:</span>         }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14">  14:</span>     });</pre>
<!--CRLF--></div>
</div>

<p></p>

<p>Which then gives better messages.</p>

<h2>For next time</h2>

<p>Ok, this is not all the JQuery Validation library can do, there is a lot more, but this is enough for now.&#160; Next post will show how to validate fields using web service results, and various callbacks that can be used to customize the library.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/09/27/playing-with-jquery-validation-library/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>Elegant Code &#187; html</title>
	<atom:link href="http://elegantcode.com/category/html/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com</link>
	<description></description>
	<lastBuildDate>Tue, 15 May 2012 10:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>The Web is Not Platform Independent</title>
		<link>http://elegantcode.com/2010/08/22/the-web-is-not-platform-independent/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-web-is-not-platform-independent</link>
		<comments>http://elegantcode.com/2010/08/22/the-web-is-not-platform-independent/#comments</comments>
		<pubDate>Sun, 22 Aug 2010 20:16:32 +0000</pubDate>
		<dc:creator>John Sonmez</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/08/22/the-web-is-not-platform-independent/</guid>
		<description><![CDATA[There was a time when you wrote a web site and you targeted IE6. That time has long passed. When you really only had to target IE6, you could pretend the web was platform independent. The truth is now the web is neither, nor will ever be platform independent.&#160; It’s just an illusion based on [...]]]></description>
			<content:encoded><![CDATA[<p>There was a time when you wrote a web site and you targeted IE6.</p>  <p>That time has long passed.</p>  <p>When you really only had to target IE6, you could pretend the web was platform independent.</p>  <p>The truth is now the web is neither, nor will ever be platform independent.&#160; It’s just an illusion based on the simple notion that browsers basically just render HTML.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/08/pegi.jpg"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="pegi" border="0" alt="pegi" src="http://elegantcode.com/wp-content/uploads/2010/08/pegi_thumb.jpg" width="438" height="517" /></a></p>  <h2>How many platforms are there then?</h2>  <p>This is a surprisingly difficult question to answer.</p>  <p>Back before the web really took off there were basically 3 platforms to develop an app for: Windows; Unix/Linux; and Mac.</p>  <p>When we answer this question for the web, really we have to look at browsers as if they are the operating system.&#160; Since the same browser exists on multiple base OS’s but could be different, we have to count each combination of browser and OS as a potentially separate version.</p>  <p>Windows: IE6, IE7, IE8, IE9 (beta), Firefox, Chrome, Safari</p>  <p>OSX: IE, Firefox, Safari (more?)</p>  <p>Linux: Firefox, Chrome</p>  <p>Android: Webkit</p>  <p>iPad, iPhone: Safari</p>  <p>I don’t have nearly every combination listed, but this is what I would consider a good coverage for any kind of public facing website.</p>  <p>Oh, don’t forget to cross this again with localization and globalization, because you might have a localization problem that only happens in a certain language in a certain browser on a certain OS.</p>  <h2>Not just rendering level differences</h2>  <p>It is also very interesting to consider that a web developer now has to consider how their site will not just render, but be used on a mobile platform.&#160; </p>  <p>Consider how Google released an iPad version of Gmail.&#160; And although, you may not really care if your site works on an iPhone or an Android phone, you probably should start caring about how it works on tablets like the iPad, because that market is only growing. </p>  <p><strong>If you have a website that doesn’t work on someone’s iPad when they are shopping online, do you think they will get up, go turn on the computer, and go to your site to make the purchase or they will buy from a different site with a few touches?</strong></p>  <p>With a phone size resolution, the considerations are even more important.</p>  <h2>Tools help me make the web platform independent</h2>  <p>No tool exists right now that can handle the non-technical aspects of platform independence for your web application, but let us imagine for a second that a library like JQuery really made your javascript platform independent.</p>  <p>If we were to hold onto that shaky assumption, we would need to make sure that we never wrote javascript that wasn’t written through the JQuery API.&#160; (Which happens to be an extremely leaky abstraction over javascript, CSS, and the DOM.) We would still have to make sure our HTML and CSS tags were platform independent.</p>  <p>So even if we could get parts of our development to be mostly platform independent, we would still need to test on all of the major platforms, because we could not rely on the platform independence.</p>  <p>Now, don’t get me wrong here.&#160; I love JQuery.&#160; It makes the job of a web developer so much easier.&#160; But, there is an important distinction.&#160; <strong>APIs and libraries like JQuery make it easier to write platform independent web code, but they don’t make our code platform independent.</strong></p>  <h2>What does all this mean?</h2>  <p>We’ve gotten to the point where the most platform independent technology you can use is either Flash or Silverlight.</p>  <p>I’m not sure if this is the future of development, but it very well might be.</p>  <p>One important point to draw from this realization is that we shouldn’t necessarily choose to make our application a web application, because we need it to be platform independent.&#160; It seems like about 5 years ago, the web became the default choice, because it was better to have platform independence than a rich UI.</p>  <p>Hopefully, for the sake of web developers some of these paths die off or converge, or that standards compliance becomes so good that you could really write code for one browser and expect it to work on all the others.</p>  <h6>As always, you can subscribe to this <a href="http://feeds2.feedburner.com/ElegantCode">RSS feed</a> to follow my posts on elegant code.&#160; Feel free to check out my main personal blog at <a href="http://simpleprogrammer.com">http://simpleprogrammer.com</a>, which has a wider range of posts, updated 2-3 times a week.&#160; Also, you can follow me on twitter <a href="http://twitter.com/jsonmez">here</a>.</h6>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/08/22/the-web-is-not-platform-independent/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Your JavaScript goes WHERE?</title>
		<link>http://elegantcode.com/2010/03/30/your-javascript-goes-where/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=your-javascript-goes-where</link>
		<comments>http://elegantcode.com/2010/03/30/your-javascript-goes-where/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 03:35:37 +0000</pubDate>
		<dc:creator>Chris Brandsma</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/03/30/your-javascript-goes-where/</guid>
		<description><![CDATA[Let me start by saying that I was not trying to be controversial.  I was at Boise Code Camp giving a session about Asp.Net MVC, and I happened to mention that JavaScript was supposed to go at the bottom of your page.  Plus, I said this in a “of course you all know this already” [...]]]></description>
			<content:encoded><![CDATA[Let me start by saying that I was not trying to be controversial.  I was at Boise Code Camp giving a session about Asp.Net MVC, and I happened to mention that JavaScript was supposed to go at the bottom of your page.  Plus, I said this in a “of course you all know this already” type of voice, thinking this needed no further explanation.

Then the hands started raising.  Quickly, I might add.  I had to explain myself.  Yes, JavaScript goes at the bottom of your page.  Yes, I realize that we were all taught, back in the day, that JavaScript’s true home was in the &lt;head&gt; element.  In fact, <a href="http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery">many sample pages still show JavaScript at the top</a>.  But we probably learned that ten years ago, you have to think a few things have changed…except IE6 – that sucker is going to live forever!  Anyway, I’m not the type that like to stand up in a crowd and say “everything you, and everyone you know, is doing is wrong” (I’m not that smart).  And if I do, I want to come with some substantial proof.

To start, <a href="http://www.w3.org/TR/REC-html40/interact/scripts.html#h-18.2.1">where does the w3c say the SCRIPT element is supposed to go?</a>  If you read the document in the link, SCRIPT can live in either the HEAD or the BODY elements. So technically, both places are legal.  I am stating this so that no one come back and tells me I’m breaking any fundamental web rules.  If the w3c says it is ok, then it is ok darn it.
<h2>But why the bottom of the page? </h2>
That one is slightly harder to explain.  But here are the basics:  when a browser loads a document there are only so many thread for processing the document and download all the other crap that you put on the page <a href="http://theoatmeal.com/comics/design_hell">so it pops</a> (so, images and css, not to mention the bagillion font tags that Word likes to put in html).  There is also an unwritten rule that JavaScript should enhance the page after it is loaded.  So any time the browser spends parsing JavaScript is time it could be using to make the page look right.  Also, with some browsers, when the browser is loading JavaScript, ALL OTHER ACTIVITY STOPS.  Nothing else is downloaded, the browser is at a standstill until all the script is parsed – and <a href="http://ejohn.org/blog/javascript-performance-rundown/">you know how fast IE is at JavaScript.</a>

Lets be clear about this “rule”.  <a href="http://developer.yahoo.com/performance/rules.html#js_bottom">I did not make this up.</a>  But there are other ways around the performance penalty, you can also <a href="http://code.google.com/speed/page-speed/docs/payload.html#DeferLoadingJS">defer load</a> your JavaScript.  Also, putting all of the JavaScript into a single, external file is a great idea.  With a external file you get the added benefit of the JavaScript file being cached by the browser (Note: great for the user – pain for your tester.  Repeat after me, “CLEAR YOUR CACHE” often when testing).

OK, so let us review.

<a href="http://elegantcode.com/wp-content/uploads/2010/03/image17.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" src="http://elegantcode.com/wp-content/uploads/2010/03/image_thumb17.png" border="0" alt="image" width="823" height="594" /></a>
<h2>But how bad is this?</h2>
That is a fair question as well.  Truthfully, it depends.  I know that is my stock answer, but I’m talking about how much this will affect the user.  It could be nothing.  But if you have a lot of JavaScript on the page, it could be significant.   Potentially it could be as annoying as a blink tag.  Even worse it might be on par with ESPN and their auto-playing videos.   But, if we are talking about 10-20 lines of script, there could be no change at all in render time. I will say this, by moving the script to the bottom of the page I have taken pages that were not usable for 10 seconds, improved it to moments (the page had a LOT of JavaScript…and it was a very noble cause).
<h2>What else should I be doing that I’m not?</h2>
This one is easy.  Run all of your pages through <a href="http://developer.yahoo.com/yslow/">YSlow</a> and <a href="http://code.google.com/speed/page-speed/">PageSpeed</a> (you need FireFox and <a href="http://getfirebug.com/">Firebug</a> installed for this) and find out.  Also, you don’t have to be perfect as far as these tools are concerned.  Some of the rule are probably not practical either (the “You should be using a CDN for images” rule comes to mind).  But it is good to know where you can improve.  PageSpeed has a number of really nice tools as well.  It will return you properly sized images, and compressed CSS and JavaScript if you ask it.]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/03/30/your-javascript-goes-where/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Introducing oEmbed</title>
		<link>http://elegantcode.com/2010/03/05/introducing-oembed/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=introducing-oembed</link>
		<comments>http://elegantcode.com/2010/03/05/introducing-oembed/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 06:12:08 +0000</pubDate>
		<dc:creator>cory.isakson</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[WebServices]]></category>
		<category><![CDATA[oembed]]></category>

		<guid isPermaLink="false">http://elegantcode.com/?p=3325</guid>
		<description><![CDATA[Gadgets, widgets, flash, ActiveX, Silverlight, json, xml With all of the competing technologies for content embedding and resource sharing on the web it can be difficult to determine which options to use.  Have you ever wished that you could embed YouTube videos and Flickr photos into your site just by knowing the consumer friendly URLi’s [...]]]></description>
			<content:encoded><![CDATA[Gadgets, widgets, flash, ActiveX, Silverlight, json, xml

With all of the competing technologies for content embedding and resource sharing on the web it can be difficult to determine which options to use.  Have you ever wished that you could embed YouTube videos and Flickr photos into your site just by knowing the consumer friendly URLi’s to them?  That is exactly what <a href="http://oembed.com">oEmbed</a> provides.  I would like to introduce you to the basics of the specification.  I hope the simplicity encourages you to support it as a provider and as a consumer when embedding resources from other providers.  Many popular sites already support it!
<blockquote>oEmbed is a format for allowing an embedded representation of a URL on third party sites. The simple API allows a website to display embedded content (such as photos or videos) when a user posts a link to that resource, without having to parse the resource directly.</blockquote>
Lets take a look at each side of a provider and consumer scenario to illustrate how oEmbed provides and elegant solution for each.
<blockquote>Providers must specify one or more URL scheme and API endpoint pairs. The URL scheme describes which URLs provided by the service may have an embedded representation.</blockquote>
The publisher must determine what scheme(s) they support in very basic format.  Typically the scheme matches URLs that consumers would browse resources at normally.  The YouTube API, for example, supports URLs matching the scheme <a href="http://*.youtube.com/watch">http://*.youtube.com/watch</a>*

The API endpoint is simply an http URL at which consumers request oEmbed representations of the resources you provide.  Most of the current providers offer API endpoints with obvious URL’s like <a title="http://www.youtube.com/oembed" href="http://www.youtube.com/oembed">http://www.youtube.com/oembed</a> and <a title="http://www.flickr.com/services/oembed/" href="http://www.flickr.com/services/oembed/">http://www.flickr.com/services/oembed/</a>.

Once you have the endpoint you just need to host a service there that accepts 4 specific query parameters:

url : The urlencoded url that matches a supported provider defined scheme.
maxwidth : (optional) The maximum width you want for embedding the resource.
maxheight : (optional) The maximum height you want for embedding the resource.
format: (optional) xml or json are the possible values that determine the consumers desired response Content-Type.
<blockquote>Requests sent to the API endpoint must be HTTP GET requests, with all arguments sent as query parameters. All arguments must be urlencoded (as per RFC 1738).</blockquote>
oEmbed consumers make requests for the oEmbed representation of a resource by sending a basic GET request to an API endpoint with url query parameters and any optional parameters they choose.

A request to <a title="http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3D6lbDyXu7gUQ" href="http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3D6lbDyXu7gUQ">http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3D6lbDyXu7gUQ</a> results in a json response:
<pre>{
"provider_url": "http://www.youtube.com/",
"title": "Insert a YouTube Video With oEmbed Wordpress 2.9",
"html": "&lt;object width=\"480\" height=\"295\"&gt;
    &lt;param name=\"movie\" value=\"http://www.youtube.com/v/6lbDyXu7gUQ&amp;fs=1\"&gt;&lt;/param&gt;
    &lt;param name=\"allowFullScreen\" value=\"true\"&gt;&lt;/param&gt;
    &lt;param name=\"allowscriptaccess\" value=\"always\"&gt;&lt;/param&gt;
    &lt;embed src=\"http://www.youtube.com/v/6lbDyXu7gUQ&amp;fs=1\" type=\"application/x-shockwave-flash\"
        width=\"480\" height=\"295\" allowscriptaccess=\"always\" allowfullscreen=\"true\"&gt;&lt;/embed&gt;&lt;/object&gt;",
"author_name": "adriarichards", "height": 295, "width": 480, "version": "1.0",
"author_url": "http://www.youtube.com/user/adriarichards",
"provider_name": "YouTube",
"type": "video"
}</pre>
Note the html property.  It contains everything you need to embed the video.  If this installation of WordPress was running version 2.9 I could paste a YouTube URL here and it would automatically get embeded as described in the video <a href="http://www.youtube.com/watch?v=6lbDyXu7gUQ">Insert a YouTube Video With oEmbed Wordpress 2.9</a>

oEmbed supports 4 result types including video, photo, link and rich.  The rich type allows for just about any html to be returned and thus embedded.
<blockquote>Consumers may wish to load the HTML in an off-domain iframe to avoid XSS vulnerabilities.</blockquote>
To learn more and see a list of some current providers check it out at:

<a title="http://oembed.com/" href="http://oembed.com/">http://oembed.com/</a>

And for a few more implementations check out <a title="http://oohembed.com/" href="http://oohembed.com/">http://oohembed.com/</a>

I look forward to hearing how you end up using oEmbed!]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/03/05/introducing-oembed/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JetBrains Web IDE</title>
		<link>http://elegantcode.com/2010/01/29/jetbrains-web-ide/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=jetbrains-web-ide</link>
		<comments>http://elegantcode.com/2010/01/29/jetbrains-web-ide/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 21:03:26 +0000</pubDate>
		<dc:creator>Jan Van Ryswyck</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/01/29/jetbrains-web-ide/</guid>
		<description><![CDATA[As I already mentioned in a previous blog post, I’m kind of (re-)learning HTML and CSS. The best way for me to pick things up again is by getting my hands dirty and work myself through a simple example. So I decided to work on some sort of prototype of a web application without using [...]]]></description>
			<content:encoded><![CDATA[<p>As I already mentioned in a <a href="http://elegantcode.com/2010/01/26/css-basics-the-box-model/">previous blog post</a>, I’m kind of (re-)learning HTML and CSS. The best way for me to pick things up again is by getting my hands dirty and work myself through a simple example. So I decided to work on some sort of prototype of a web application without using any web framework like ASP.NET MVC, Fubu MVC, Ruby on Rails, etc. … Just plain old HTML and CSS, like the Internet gods intended. I also didn’t want to suck all the fun out of it either, so I decided to use <a href="http://www.jetbrains.com/webide/index.html">Web IDE</a> from <a href="http://www.jetbrains.com/index.html">JetBrains</a> as my IDE for churning out this prototype. </p>  <p>I must say that I was pleasantly surprised by some of the features that this IDE has to offer. The first and most obvious one is probably intellisense that just works as expected.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/01/image9.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/01/image_thumb9.png" width="553" height="385" /></a> </p>  <p>Also notice the on-the-fly code inspection (colored marker bar on the right) that should be familiar when you’re a Resharper addict like me. Web IDE provides W3C XHTML/CSS validation while working in the editor which is really useful. </p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/01/image10.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/01/image_thumb10.png" width="548" height="381" /></a> </p>  <p>Being the uncertain type, it was also nice to see all the familiar refactoring features from Resharper being available as well. Renaming a class or id is just a breeze. All the corresponding HTML or CSS files are consistently updated.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/01/image11.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/01/image_thumb11.png" width="546" height="382" /></a> </p>  <p>Navigation is there as well (CTRL-N and CTRL-SHIFT-N).</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/01/image12.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/01/image_thumb12.png" width="543" height="378" /></a> </p>  <p>This looks just like <a href="http://www.jetbrains.com/resharper/index.html">Resharper</a> for web developers, but there’s more. At first, I had all the HTML and CSS files including all the image file in the root folder of the project. I wanted to divide and conquer by putting the images and CSS files into their own separate folder. As I prepared myself to change all the references in the HTML files, Web IDE did that all for me when I dragged the files to their final destination. Now I didn’t had to go over all the HTML files and manually change the links. How cool is that!</p>  <p>Web IDE also provides source-control integration Subversion, Git, Perforce, etc … and that’s just the tip of the iceberg. While working on the prototype of the web application, I mostly focused on the layout and not so much on the behavior so I didn’t use much of the JavaScript capabilities. But I was told that it is comparable with the JavaScript features in <a href="http://www.jetbrains.com/ruby/index.html">RubyMine</a> as described by Peter in <a href="http://peter.worksontheweb.net/post/An-alternative-to-editing-JavaScript-in-Visual-Studio-RubyMine.aspx">this blog post</a>. This is something that I’m going to explore when I start learning more about JavaScript :-). </p>  <p>Although being the first version and still in beta, the IDE seems pretty stable and I couldn’t notice any performance hiccups so far (which <a href="http://davybrion.com/blog/2010/01/i-still-have-low-expectations-for-visual-studio-2010/">cannot be said for all IDE’s</a> these days). </p>  <p>I do hope that there will be some support for ASP.NET or other view engines like <a href="http://sparkviewengine.com/">Spark</a>, <a href="http://nvelocity.sourceforge.net/">NVelocity</a>, etc. … in future versions. In fact, I still silently wish that JetBrains would come up with an IDE for .NET. Being realistic about it, I don’t have high hopes for something like that coming out but it would totally rock if they decided to build one. Sweet dreams :-)</p>  <p>Bottom line, when you’re doing web development in Visual Studio, make sure to also check out Web IDE. It will probably help you to become more productive along the way.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/01/29/jetbrains-web-ide/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Playing with JQuery Validation library</title>
		<link>http://elegantcode.com/2009/09/27/playing-with-jquery-validation-library/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=playing-with-jquery-validation-library</link>
		<comments>http://elegantcode.com/2009/09/27/playing-with-jquery-validation-library/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 04:21:16 +0000</pubDate>
		<dc:creator>Chris Brandsma</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JQuery]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/09/27/playing-with-jquery-validation-library/</guid>
		<description><![CDATA[New job (2 weeks in), new responsibilities, new tools to play with.&#160; Amazingly (for me), one of the new tools is the JQuery Validation Library.&#160; My diving into this also coincides with ScottGu’s announcement that Microsoft is creating their own CDN for JQuery and JQuery Validation.&#160; Bad news is that this means I’m behind.&#160; That [...]]]></description>
			<content:encoded><![CDATA[<p>New job (2 weeks in), new responsibilities, new tools to play with.&#160; Amazingly (for me), one of the new tools is the <a href="http://docs.jquery.com/Plugins/Validation">JQuery Validation Library</a>.&#160; My diving into this also coincides with ScottGu’s announcement that Microsoft is creating their own <a href="http://weblogs.asp.net/scottgu/archive/2009/09/15/announcing-the-microsoft-ajax-cdn.aspx">CDN for JQuery and JQuery Validation</a>.&#160; </p>  <p>Bad news is that this means I’m behind.&#160; That sucks.&#160; I was using JQuery MONTHS before Microsoft officially started supporting it (at least 6 months – but I’m too lazy to look it up).&#160; Anyway, now you can use Microsoft’s bandwidth to get JQuery to your customer’s browser with this line:</p>  <p>&lt;script src=&quot;http://ajax.microsoft.com/ajax/jquery/jquery-1.3.2.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</p>  <p>And you can add the JQuery Validation library like this: </p>  <p>&lt;script src=&quot;http://ajax.microsoft.com/ajax/jquery.validate/1.5.5/jquery.validate.js&quot; type=”text/javascript”&gt;&lt;/script&gt;</p>  <p>Note: see those end tags, great annoyance of my life, but you have to have them, you can’t do &lt;script src=”http://…” /&gt;.&#160; That sucks, but I’m learning to live with it.</p>  <p>Anyway, back to validation.</p>  <p>The more I play with this library, the more I like it.&#160; It is very configurable, easily style-able, the documentation isn’t half bad, and the code is readable.</p>  <h2>Getting Started with JQuery Validation:</h2>  <p><strong>The JavaScript Way:</strong>&#160; OK, assuming you have JQuery and the JQuery Validation library included, lets start with a simple customer form:</p>  <p></p>  <div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">   <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">     <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">form</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;CustomerForm&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;firstNameEdit&quot;</span><span style="color: #0000ff">&gt;</span>First Name:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;firstNameEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;LastNameEdit&quot;</span><span style="color: #0000ff">&gt;</span>Last Name:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;LastNameEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;EmailEdit&quot;</span><span style="color: #0000ff">&gt;</span>Email:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12">  12:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;EmailEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13">  13:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14">  14:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum15">  15:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">button</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;submit&quot;</span><span style="color: #0000ff">&gt;</span>Submit<span style="color: #0000ff">&lt;/</span><span style="color: #800000">button</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum16">  16:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum17">  17:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">form</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF--></div>
</div>

<p>Nothing special there.&#160; Just a bunch of inputs and labels.&#160; If you hit the submit button, a postback is fired and the data is sent back to the server.</p>

<p>But, business requirements dictate that all fields are required.&#160; Simple enough, using JQuery the hookup looks like this:</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> $(<span style="color: #006080">&quot;#CustomerForm&quot;</span>).validate({</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span>     rules: {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span>       FirstNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>       LastNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>       EmailEdit: { required: <span style="color: #0000ff">true</span>, email:<span style="color: #0000ff">true</span> }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>     }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span> });</pre>
<!--CRLF--></div>
</div>

<p>OK, the first name, last name, and email will now be required.&#160; I also threw a little extra in there: email validation.&#160; If you submit the form like this will be added after any of the required fields:</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> &lt;label <span style="color: #0000ff">class</span>=<span style="color: #006080">&quot;error&quot;</span> <span style="color: #0000ff">for</span>=<span style="color: #006080">&quot;FirstName&quot;</span> generated=<span style="color: #006080">&quot;true&quot;</span>&gt;This field <span style="color: #0000ff">is</span> required.&lt;/label&gt;</pre>
<!--CRLF--></div>
</div>

<p>Key part there is the ‘error’ css class which is great for styling the messages.&#160; So you can use the ‘label.error’ in your css class.</p>

<h2>Another way</h2>

<p>You can also use css classes to setup which fields are required.&#160; It is a nice and simple way to hook everything up, but it is not as easily configurable (as we will see in a moment):</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">form</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;CustomerForm&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;FirstNameEdit&quot;</span><span style="color: #0000ff">&gt;</span>First Name:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;FirstNameEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot;</span> class=”required”<span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;LastNameEdit&quot;</span><span style="color: #0000ff">&gt;</span>Last Name:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;LastNameEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot; class=”required”</span> <span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">label</span> <span style="color: #ff0000">for</span><span style="color: #0000ff">=&quot;EmailEdit&quot;</span><span style="color: #0000ff">&gt;</span>Email:<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12">  12:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">input</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;EmailEdit&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text&quot;</span> class=”required email”<span style="color: #0000ff">/&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13">  13:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14">  14:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum15">  15:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">button</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;submit&quot;</span><span style="color: #0000ff">&gt;</span>Submit<span style="color: #0000ff">&lt;/</span><span style="color: #800000">button</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum16">  16:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum17">  17:</span> <span style="color: #0000ff">&lt;/form</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF--></div>
</div>

<p>The the Javascript is actually much simpler:</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> $(<span style="color: #006080">&quot;CustomerForm&quot;</span>).validate();</pre>
<!--CRLF--></div>
</div>

<p>And you will get the same results.&#160; But, the rest of the samples will use the prior code setup.&#160; Also note: you can mix and match the css style with the JavaScript style.</p>

<h2>Moving the message</h2>

<p>Next problem you might encounter is you want to move the messages to another part of the screen.&#160; Remember, default behavior is the messages go next to the control.</p>

<p>To solve this we will add a div to the page:</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 31px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">div</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;RegisterErrors&quot;</span> <span style="color: #ff0000">style</span><span style="color: #0000ff">=&quot;display:none&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<!--CRLF--></div>
</div>

<p>I can setup the Validation library to use this by going back to the validate method and adding errorLabelContainer directive.</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> $(“#CustomerForm”).validate({</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> <strong>errorLabelContainer: $(<span style="color: #006080">&quot;#RegisterErrors&quot;</span>),</strong></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> rules: {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>         FirstNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>         LastNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>         EmailEdit: { required: <span style="color: #0000ff">true</span>, email: <span style="color: #0000ff">true</span> }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>     }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span> });</pre>
<!--CRLF--></div>
</div>

<p>Now this is great, but there is still a problem.&#160; Each of the messages will be “This field is required”.&#160; That doesn’t say which field is the problem.&#160; Lets add custom messages for each field.</p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> </pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span>     $(<span style="color: #006080">&quot;#CustomerForm&quot;</span>).validate({</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span>     errorLabelContainer: $(<span style="color: #006080">&quot;#RegisterErrors&quot;</span>),</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>     rules: {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>             FirstNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>             LastNameEdit: { required: <span style="color: #0000ff">true</span> },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>             EmailEdit: { required: <span style="color: #0000ff">true</span>, email: <span style="color: #0000ff">true</span> }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span>         },</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span>         messages: {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span>             FirstNameEdit: <span style="color: #006080">&quot;First name is required&quot;</span>,</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span>             LastNameEdit: <span style="color: #006080">&quot;Last name is required&quot;</span>,</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12">  12:</span>             EmailEdit: <span style="color: #006080">&quot;Valid email address is required&quot;</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13">  13:</span>         }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14">  14:</span>     });</pre>
<!--CRLF--></div>
</div>

<p></p>

<p>Which then gives better messages.</p>

<h2>For next time</h2>

<p>Ok, this is not all the JQuery Validation library can do, there is a lot more, but this is enough for now.&#160; Next post will show how to validate fields using web service results, and various callbacks that can be used to customize the library.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/09/27/playing-with-jquery-validation-library/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>FireFox+Firebug vs IE8 Developer Toolbar</title>
		<link>http://elegantcode.com/2009/05/18/firefoxfirebug-vs-ie8-developer-toolbar/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=firefoxfirebug-vs-ie8-developer-toolbar</link>
		<comments>http://elegantcode.com/2009/05/18/firefoxfirebug-vs-ie8-developer-toolbar/#comments</comments>
		<pubDate>Tue, 19 May 2009 04:33:09 +0000</pubDate>
		<dc:creator>Chris Brandsma</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/05/18/firefoxfirebug-vs-ie8-developer-toolbar/</guid>
		<description><![CDATA[A long while back I posted that IE8 was shipping with a new Developer Toolbar that was very similar to FireFox’s Firebug.  Now that I’ve had several month to play with each, I thought it was time to comment on the two of them. First off: both tools are wonderful.  If you are doing web [...]]]></description>
			<content:encoded><![CDATA[A long while back I posted that <a href="http://elegantcode.com/2008/03/06/ie-team-ports-firebug-to-ie8/">IE8 was shipping with a new Developer Toolbar</a> that was very similar to FireFox’s <a href="http://getfirebug.com/">Firebug</a>.  Now that I’ve had several month to play with each, I thought it was time to comment on the two of them.

First off: both tools are wonderful.  If you are doing web development (JavaScript heavy or not), do yourself a favor and install BOTH of them.  If you are using IE7, upgrade.  If you are using IE6 … may the gods be merciful on your soul.  Actually, let me restate that: There are no redeeming qualities to IE6 as to put up with it except by threat of violence.  Get rid of the beast.  (Then <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=21EABB90-958F-4B64-B5F1-73D0A413C8EF&amp;displaylang=en">download the IE6 vm from Microsoft</a>).

I know .Net/C# developers that almost refuse to help you unless you have ReSharper installed.  Same goes for web developers these days.  You need IE8 and FireFox+FireBug.  It is that important.

Moving along then.

Getting started with either of them is fairly similar.  F12 is your friend.  Click F12 and you will get on of the two displays below.  You see color coded html, code folding, and display of css style information.

<a href="http://elegantcode.com/wp-content/uploads/2009/05/image4.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://elegantcode.com/wp-content/uploads/2009/05/image-thumb3.png" border="0" alt="image" width="244" height="128" /></a> <a href="http://elegantcode.com/wp-content/uploads/2009/05/image5.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://elegantcode.com/wp-content/uploads/2009/05/image-thumb4.png" border="0" alt="image" width="244" height="138" /></a>

OK, to write everything out would take too long.  Here is a breakdown:
<table border="1" cellspacing="0" cellpadding="2" width="452">
<tbody>
<tr>
<td width="98" valign="top"><strong><span style="font-size: small;">Feature</span></strong></td>
<td width="33" valign="top"><strong><span style="font-size: small;">IE8 </span></strong></td>
<td width="148" valign="top"><strong><span style="font-size: small;">FireBug
+FireFox</span></strong></td>
<td width="46" valign="top"><strong><span style="font-size: small;">Opera</span></strong></td>
<td width="43" valign="top"><strong><span style="font-size: small;">Safari</span></strong></td>
<td width="7" valign="top"><strong><span style="font-size: small;">Chrome</span></strong></td>
<td width="75" valign="top"><strong><span style="font-size: small;">Usefulness</span></strong></td>
</tr>
<tr>
<td width="98" valign="top"><strong>HTML</strong></td>
<td width="33" valign="top"></td>
<td width="148" valign="top"></td>
<td width="46" valign="top"></td>
<td width="43" valign="top"></td>
<td width="7" valign="top"></td>
<td width="75" valign="top"></td>
</tr>
<tr>
<td width="98" valign="top">Syntax Highlighting</td>
<td width="33" valign="top">Yes</td>
<td width="148" valign="top">Yes</td>
<td width="46" valign="top">Yes</td>
<td width="43" valign="top">Yes</td>
<td width="7" valign="top">Yes</td>
<td width="75" valign="top"><a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a> <a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a></td>
</tr>
<tr>
<td width="98" valign="top">Code Folding</td>
<td width="33" valign="top">Yes</td>
<td width="148" valign="top">Yes</td>
<td width="46" valign="top">Yes</td>
<td width="43" valign="top">Yes</td>
<td width="7" valign="top">Yes</td>
<td width="75" valign="top"><a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a> <a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a></td>
</tr>
<tr>
<td width="98" valign="top">Html Editing</td>
<td width="33" valign="top">Yes</td>
<td width="148" valign="top">Yes</td>
<td width="46" valign="top">No</td>
<td width="43" valign="top">No</td>
<td width="7" valign="top">No</td>
<td width="75" valign="top"><a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a> <a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a> <a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a></td>
</tr>
<tr>
<td width="98" valign="top">HTML Validator</td>
<td width="33" valign="top">Yes*</td>
<td width="148" valign="top">No</td>
<td width="46" valign="top">No</td>
<td width="43" valign="top">No</td>
<td width="7" valign="top">No</td>
<td width="75" valign="top"><a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a></td>
</tr>
<tr>
<td width="98" valign="top">Clear Cache</td>
<td width="33" valign="top">Yes</td>
<td width="148" valign="top">No**</td>
<td width="46" valign="top">No**</td>
<td width="43" valign="top">No**</td>
<td width="7" valign="top">No**</td>
<td width="75" valign="top"><a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a> <a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a></td>
</tr>
<tr>
<td width="98" valign="top">Select and Highlight</td>
<td width="33" valign="top">Yes</td>
<td width="148" valign="top">Yes</td>
<td width="46" valign="top">Yes</td>
<td width="43" valign="top">Yes</td>
<td width="7" valign="top">Yes</td>
<td width="75" valign="top"><a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a> <a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a> <a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a> <a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a></td>
</tr>
<tr>
<td width="98" valign="top">Layout</td>
<td width="33" valign="top">Yes</td>
<td width="148" valign="top">Yes</td>
<td width="46" valign="top">Yes</td>
<td width="43" valign="top">Yes</td>
<td width="7" valign="top">Yes</td>
<td width="75" valign="top"><a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a> <a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a></td>
</tr>
<tr>
<td width="98" valign="top"><strong>CSS</strong></td>
<td width="33" valign="top"></td>
<td width="148" valign="top"></td>
<td width="46" valign="top"></td>
<td width="43" valign="top"></td>
<td width="7" valign="top"></td>
<td width="75" valign="top"></td>
</tr>
<tr>
<td width="98" valign="top">Css Viewer/Editor</td>
<td width="33" valign="top">Yes</td>
<td width="148" valign="top">Yes</td>
<td width="46" valign="top">Yes</td>
<td width="43" valign="top">Yes</td>
<td width="7" valign="top">Yes</td>
<td width="75" valign="top"><a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a> <a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a> <a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a> <a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a></td>
</tr>
<tr>
<td width="98" valign="top">Css Syntax Highlight</td>
<td width="33" valign="top">Yes</td>
<td width="148" valign="top">Yes</td>
<td width="46" valign="top">No</td>
<td width="43" valign="top">No</td>
<td width="7" valign="top">No</td>
<td width="75" valign="top"><a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a> <a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a></td>
</tr>
<tr>
<td width="98" valign="top">Disable CSS Styles</td>
<td width="33" valign="top">Yes</td>
<td width="148" valign="top">Yes</td>
<td width="46" valign="top">No</td>
<td width="43" valign="top">No</td>
<td width="7" valign="top">No</td>
<td width="75" valign="top"><a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a> <a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a></td>
</tr>
<tr>
<td width="98" valign="top">Create New Styles</td>
<td width="33" valign="top">Yes</td>
<td width="148" valign="top">Yes</td>
<td width="46" valign="top">No</td>
<td width="43" valign="top">No</td>
<td width="7" valign="top">No</td>
<td width="75" valign="top"><a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a> <a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a></td>
</tr>
<tr>
<td width="98" valign="top">Validate CSS</td>
<td width="33" valign="top">Yes*</td>
<td width="148" valign="top">No</td>
<td width="46" valign="top">No</td>
<td width="43" valign="top">No</td>
<td width="7" valign="top">No</td>
<td width="75" valign="top"><a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a></td>
</tr>
<tr>
<td width="98" valign="top"><strong>JavaScipt</strong></td>
<td width="33" valign="top"></td>
<td width="148" valign="top"></td>
<td width="46" valign="top"></td>
<td width="43" valign="top"></td>
<td width="7" valign="top"></td>
<td width="75" valign="top"></td>
</tr>
<tr>
<td width="98" valign="top">Javascript Highlight</td>
<td width="33" valign="top">Yes</td>
<td width="148" valign="top">No</td>
<td width="46" valign="top">Yes</td>
<td width="43" valign="top">Yes</td>
<td width="7" valign="top">No</td>
<td width="75" valign="top"><a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a></td>
</tr>
<tr>
<td width="98" valign="top">JavaScript Debug</td>
<td width="33" valign="top">Yes</td>
<td width="148" valign="top">Yes</td>
<td width="46" valign="top">Yes</td>
<td width="43" valign="top">Yes</td>
<td width="7" valign="top">No***</td>
<td width="75" valign="top"><a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a> <a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a> <a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a> <a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a></td>
</tr>
<tr>
<td width="98" valign="top">Breakpoints</td>
<td width="33" valign="top">Yes</td>
<td width="148" valign="top">Yes</td>
<td width="46" valign="top">Yes</td>
<td width="43" valign="top">Yes</td>
<td width="7" valign="top">No***</td>
<td width="75" valign="top"><a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a> <a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a> <a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a> <a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a></td>
</tr>
<tr>
<td width="98" valign="top">Step Over/In/Out</td>
<td width="33" valign="top">Yes</td>
<td width="148" valign="top">Yes</td>
<td width="46" valign="top">Yes</td>
<td width="43" valign="top">Yes</td>
<td width="7" valign="top">No***</td>
<td width="75" valign="top"><a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a> <a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a> <a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a> <a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a></td>
</tr>
<tr>
<td width="98" valign="top">JavaScript Profiler</td>
<td width="33" valign="top">Yes</td>
<td width="148" valign="top">Yes</td>
<td width="46" valign="top">No</td>
<td width="43" valign="top">Yes</td>
<td width="7" valign="top">No</td>
<td width="75" valign="top"><a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a> <a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a></td>
</tr>
<tr>
<td width="98" valign="top">Execute JavaScript</td>
<td width="33" valign="top">Yes</td>
<td width="148" valign="top">Yes</td>
<td width="46" valign="top">Yes</td>
<td width="43" valign="top">Yes</td>
<td width="7" valign="top">Yes</td>
<td width="75" valign="top"><a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a> <a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a></td>
</tr>
<tr>
<td width="98" valign="top">Call Stack</td>
<td width="33" valign="top">Yes</td>
<td width="148" valign="top">Yes</td>
<td width="46" valign="top">Yes</td>
<td width="43" valign="top">Yes</td>
<td width="7" valign="top">No</td>
<td width="75" valign="top"><a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a> <a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a> <a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a></td>
</tr>
<tr>
<td width="98" valign="top">Local Variables</td>
<td width="33" valign="top">Yes</td>
<td width="148" valign="top">Yes</td>
<td width="46" valign="top">No</td>
<td width="43" valign="top">Yes</td>
<td width="7" valign="top">No</td>
<td width="75" valign="top"><a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a> <a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a> <a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a></td>
</tr>
<tr>
<td width="98" valign="top">Watch Variables</td>
<td width="33" valign="top">Yes</td>
<td width="148" valign="top">Yes</td>
<td width="46" valign="top">Yes</td>
<td width="43" valign="top">No</td>
<td width="7" valign="top">No</td>
<td width="75" valign="top"><a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a> <a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a></td>
</tr>
<tr>
<td width="98" valign="top">Web Service Viewer</td>
<td width="33" valign="top">No</td>
<td width="148" valign="top">Yes</td>
<td width="46" valign="top">No</td>
<td width="43" valign="top">No</td>
<td width="7" valign="top">No</td>
<td width="75" valign="top"><a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a> <a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a></td>
</tr>
<tr>
<td width="98" valign="top"><strong>Intangibles</strong></td>
<td width="33" valign="top"></td>
<td width="148" valign="top"></td>
<td width="46" valign="top"></td>
<td width="43" valign="top"></td>
<td width="7" valign="top"></td>
<td width="75" valign="top"></td>
</tr>
<tr>
<td width="98" valign="top">YSlow</td>
<td width="33" valign="top">No</td>
<td width="148" valign="top">Yes</td>
<td width="46" valign="top">No</td>
<td width="43" valign="top">No</td>
<td width="7" valign="top">No</td>
<td width="75" valign="top"><a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a> <a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a></td>
</tr>
<tr>
<td width="98" valign="top">Browser Mode Switch</td>
<td width="33" valign="top">Yes</td>
<td width="148" valign="top">No</td>
<td width="46" valign="top">No</td>
<td width="43" valign="top">No</td>
<td width="7" valign="top">No</td>
<td width="75" valign="top"><a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a> <a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a> <a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a></td>
</tr>
<tr>
<td width="98" valign="top">Dockable</td>
<td width="33" valign="top">Yes</td>
<td width="148" valign="top">Yes</td>
<td width="46" valign="top">Yes</td>
<td width="43" valign="top">Yes</td>
<td width="7" valign="top">Yes</td>
<td width="75" valign="top"><a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a></td>
</tr>
<tr>
<td width="98" valign="top">Color Picker</td>
<td width="33" valign="top">Yes</td>
<td width="148" valign="top">Yes*</td>
<td width="46" valign="top">No</td>
<td width="43" valign="top">No</td>
<td width="7" valign="top">No</td>
<td width="75" valign="top"><a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a></td>
</tr>
<tr>
<td width="98" valign="top">Net Tab</td>
<td width="33" valign="top">No</td>
<td width="148" valign="top">Yes</td>
<td width="46" valign="top">No</td>
<td width="43" valign="top">No</td>
<td width="7" valign="top">No</td>
<td width="75" valign="top"><a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a> <a href="http://elegantcode.com/wp-content/uploads/2009/05/star.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="star" src="http://elegantcode.com/wp-content/uploads/2009/05/star-thumb.png" border="0" alt="star" width="16" height="16" /></a></td>
</tr>
</tbody></table>
* Uses 3rd party web site
** Available in other areas of the application
*** Technically you can…but you really don’t want to.

You can see that there are a number of features missing from each tool.  That said, I think FireFox+FireBug has an advantage right now, mainly for YSlow, the Console Tab (displays web service traffic), and the Net Tab.  Those three are huge.  For the items that FireFox+Firebug are missing, you should probably install the <a href="http://chrispederick.com/work/web-developer/">Web Developer Toolbar</a> for Firefox.  I tend to install both of those on every machine I own.

For IE8, the fact that you can switch between IE7 and IE8 mode, Standard and Quirks Mode is also huge.  The built in Html/CSS validation doesn’t hurt either.  But what really shines in IE8 is the built in tools.  Color selection, Cache Management, Outline, Image, etc.  To get those in FireFox you need the <a href="http://chrispederick.com/work/web-developer/">Web Developer Toolbar</a> for Firefox.  To see the web service traffic in IE8 (that Firebug gives you), you need to get <a href="http://www.fiddler2.com/fiddler2/">Fiddler2</a>.  Actually, you should have Fiddler for both browsers.
<h3>But what about those other browsers:</h3>
<strong>Google Chrome:</strong> Chrome has its Developer menu which contains a primitive set of the features listed.  It is missing quite a bit, but it is able to view html, css, and JavaScript, debug JavaScript, modify css on the fly, and a few other items.  All things considered, it isn’t bad, but Chrome is well behind the other two browser for functionality.

<strong>Apple Safari:</strong> <span style="text-decoration: line-through;">Lions and tigers and bears – oh my!  Test in Google Chrome.  Hope it works in Safari. </span>

EDIT: I was show the error of my ways with Safari.  Safari does have developer tools – and they are EXACTLY what you get from Google Chrome, plus some extras.  Which makes sense, after all the two browsers use the same code base – but come on, at least get some new icons!

But to find the developer tools, you have to show the menu bar.  Then go to preferences, Advanced Tab, and check “Show Develop menu in menu bar”.   Next go to the Develop menu and select “Show Web Inspector”.  Actually, check out everything in that menu.

What do you get: you get a better JavaScript debugger than what Chrome has.  The Resources tab works.  A profiler (nice touch).  But there is this Databases thing that I know nothing about.

I still don’t think Safari is better than Firefox or IE8, but it is an improvement on what you get with Chrome.

<strong>Opera</strong>: I had some trouble getting the Opera tools to work.  Could be me.  But all said and done, the tools you get are serviceable.
<h2>And the winner is…</h2>
You the web developer, who for years has toiled away in the archaic knowledge of proper alert placement.  You win.  Both these tools are wonderful, I just wish we had them long ago. That said, it is hard not to give FireFox+FireBug a slight advantage in this race.

<em><strong>EDIT: </strong></em> Since the initial publication, Mozilla has released the Web Developer Toolbox Collection
<a href="https://addons.mozilla.org/en-US/firefox/collection/webdeveloper">https://addons.mozilla.org/en-US/firefox/collection/webdeveloper</a>
This includes Firebug, YSlow, ColorZilla, Web Developer Toolbar, and more.  Please just get the collection.
<h6>Note: Star Image via FamFamFam</h6>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/05/18/firefoxfirebug-vs-ie8-developer-toolbar/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
	</channel>
</rss>

