<?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>Dwight Jack Diary &#187; semantic label</title>
	<atom:link href="http://www.dwightjack.com/diary/tag/semantic-label/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dwightjack.com/diary</link>
	<description>Diary of music, design and code</description>
	<lastBuildDate>Tue, 13 Jul 2010 20:46:53 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Semantic in-field input label with jQuery</title>
		<link>http://www.dwightjack.com/diary/2008/12/24/semantic-in-field-input-label-with-jquery/</link>
		<comments>http://www.dwightjack.com/diary/2008/12/24/semantic-in-field-input-label-with-jquery/#comments</comments>
		<pubDate>Wed, 24 Dec 2008 08:00:43 +0000</pubDate>
		<dc:creator>Dwight Jack</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[jQuery plugin]]></category>
		<category><![CDATA[semantic label]]></category>

		<guid isPermaLink="false">http://www.dwightjack.com/diary/?p=25</guid>
		<description><![CDATA[Recent moods on input fields presentation tend to insert as initial value of an empty form field its label value.
An example of this can be found on the Facebook Homepage.
Though this is a space saving way to show labels and a much more focused way to point out the expected field value, addressing it by [...]]]></description>
			<content:encoded><![CDATA[<p>Recent moods on input fields presentation tend to insert as initial value of an empty form field its label value.</p>
<p>An example of this can be found on the <strong>Facebook Homepage</strong>.</p>
<div id="attachment_28" class="wp-caption aligncenter" style="width: 310px"><img class="size-medium wp-image-28" title="facebook-input-labels" src="http://www.dwightjack.com/diary/wp-content/uploads/2008/12/facebook-input-labels-300x63.png" alt="Facebook Input Label" width="300" height="63" /><p class="wp-caption-text">Facebook Input Label</p></div>
<p>Though this is a space saving way to show labels and a much more focused way to point out the expected field value, addressing it by the <code>value</code> attribute introduces a semantic issue, since that&#8217;s not at all an initial value, not counting that pulling apart the<code> label</code> tag is an accessibility fault.</p>
<p>To overcome this problem we can rely on the powerfull JavaScript framework <strong><a href="http://www.jquery.com/" target="_blank">jQuery</a></strong>, to build an unobtrusive plugin mantaining both accessibility and usability. Let&#8217;s see:</p>
<p>1) Link the script in the head section:</p>
<pre><code>&lt;script src="jquery.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script src="jquery.inputLabel.js" type="text/javascript"&gt;&lt;/script&gt;</code></pre>
<p>2) Semantically correct XHTML:</p>
<pre><code>&lt;label for="myInput"&gt;Email here&lt;label&gt;&lt;nput type="text" name="myInput" id="myInput" /&gt;</code></pre>
<p>3) Run the plugin on document load (place this in a script tag before the end of head):</p>
<pre class="js"><code>$(function () {
      $("#myInput").inputLabel();
});
</code></pre>
<p>That&#8217;s all. You can pass an options&#8217; object to change, for example, the inserted value, or to prevent the plugin for running on already filled or pre-filled fields:</p>
<ul class="list">
<li><em>color</em>: initial text color (default : &#8220;#666&#8243;)</li>
<li><em>e</em>: event which triggers label text clearing (default: &#8220;focus&#8221;)</li>
<li><em>force</em>: execute this script even if input value is not empty (default: false)</li>
<li><em>keep</em>: if value of field is empty on blur, re-apply label text (default: true)</li>
</ul>
<p>Check the <strong><a href="http://www.dwightjack.com/demos/inputlabel/" target="_blank">demo page</a></strong> to see the script in action or download the source code below:<br />
<a href=http://www.dwightjack.com/diary/wp-content/plugins/download-monitor/download.php?id=1>jQuery inputLabel Plugin (2.18 kB)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.dwightjack.com/diary/2008/12/24/semantic-in-field-input-label-with-jquery/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
