<?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>Monday By Noon &#187; form</title>
	<atom:link href="http://mondaybynoon.com/tag/form/feed/" rel="self" type="application/rss+xml" />
	<link>http://mondaybynoon.com</link>
	<description>A resource for Web designers and developers to read about and discuss their craft.</description>
	<lastBuildDate>Mon, 06 Sep 2010 18:50:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Creating Custom Form Elements Using jQuery: Selects</title>
		<link>http://mondaybynoon.com/2009/02/23/creating-custom-form-elements-using-jquery-selects/</link>
		<comments>http://mondaybynoon.com/2009/02/23/creating-custom-form-elements-using-jquery-selects/#comments</comments>
		<pubDate>Mon, 23 Feb 2009 06:39:34 +0000</pubDate>
		<dc:creator>Jonathan Christopher</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[elements]]></category>
		<category><![CDATA[enhancement]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[progressive]]></category>
		<category><![CDATA[select]]></category>
		<category><![CDATA[widgets]]></category>

		<guid isPermaLink="false">http://mondaybynoon.com/?p=385</guid>
		<description><![CDATA[How to progressively enhance your form select dropdowns using JavaScript (jQuery)]]></description>
			<content:encoded><![CDATA[<p>In Web design, there are a number of guidelines to follow. Guidelines based on past experience, user data, and other various sources of information used to support good design practice. There are entire schools of thought surrounding certain guidelines, many of which undergo rounds of scrutiny and revision on a consistent basis. One particular sect of Web design that I have become increasingly interested in is that of conventions used in <code>form</code> design.</p>
<p>We all know what it&#8217;s like to use a terribly designed form; <em>irritating</em>. It&#8217;s difficult enough to get an average reader to take the time to fill out a <code>form</code>, and not following a basic ruleset can turn away any reader in the blink of an eye.</p>
<p>One particular aspect of <code>form</code> design that has been partially taboo is the revision and customization of input widgets. The trouble with form widgets is the uniqueness not only between browsers, but operating systems especially. Altering input elements your reader has become intimately accustomed to using is not a practice to be taken lightly.</p>
<p>A recent client project brought about rare circumstances under which my team felt comfortable experimenting with some custom <code>form</code> widgets. After the first rounds of design had been put together, the custom <code>form</code> elements did an extraordinary job bringing the entire concept together. We decided to run with it. By far the most unique element was the <code>select</code>.</p>
<p>I knew from the start that the <code>selects</code> would be progressively enhanced, defaulting to stock browser <code>form</code> elements out of the box. We&#8217;ve all seen custom <code>form</code> elements before, and I knew there were some pre-fabricated solutions out there. There are even plugins for <a href="http://www.jquery.com">jQuery</a> already. I had a look, but ultimately decided I would roll my own. I&#8217;d like to walk through my thought process as I prototyped a visual example for the client.</p>
<h2>Laying the foundation for a custom select</h2>
<p>What we&#8217;ll first begin with is the markup I use when including a <code>select</code> in my forms:</p>
<pre class="sh_html"><code>&lt;form id=&quot;frm_prototype&quot; action=&quot;index.php&quot; method=&quot;post&quot;&gt;
  &lt;fieldset&gt;
    &lt;legend&gt;Custom Select Test&lt;/legend&gt;
    &lt;div class=&quot;select&quot;&gt;
      &lt;label for=&quot;misc&quot;&gt;Misc&lt;/label&gt;
      &lt;select name=&quot;misc&quot;&gt;
        &lt;option value=&quot;1&quot;&gt;One&lt;/option&gt;
        &lt;option value=&quot;2&quot;&gt;Two&lt;/option&gt;
        &lt;option value=&quot;3&quot;&gt;Three&lt;/option&gt;
      &lt;/select&gt;
    &lt;/div&gt;
    &lt;div class=&quot;buttons&quot;&gt;
      &lt;button type=&quot;submit&quot; id=&quot;submit&quot; name=&quot;submit&quot;&gt;Submit&lt;/button&gt;
    &lt;/div&gt;
  &lt;/fieldset&gt;
&lt;/form&gt;</code></pre>
<p>Your markup may very well differ, as my past experience shows that various designers are slightly particular about <code>form</code> markup. I also began with just a bit of simple CSS on top of that:</p>
<pre class="sh_css"><code>form { margin-bottom:25px; }
form fieldset { border:0; }
form div { clear:left; padding:10px 0; }
form legend { font-size:16px; font-weight:bold; }
form label { display:block; width:75px; float:left; }
form select { display:block; width:225px; float:left; }
form button { padding:5px; }</code></pre>
<p class="single_link"><a href="http://mondaybynoon.com/examples/custom-select/step-1/">View Step 1</a> (note: form submission <em>is not functional</em>)</p>
<h3>Making a plan for the customization</h3>
<p>I wanted to keep the progressive enhancement as semantic as possible, so I took a step back and thought about what a <code>select</code> represented, save the functionality. To me, a <code>select</code> includes a representative item from a set of available alternatives. In essence, the chosen value defines the <code>select</code>. The defining relationship stuck, and I elected to base my markup variations around a definition list.</p>
<p>Next, I took a few minutes to think about how I planned on executing the progressive enhancement. I came up with the following list of steps I&#8217;d take to recreate the interaction of the original <code>select</code> while retaining the integrity of the <code>form</code> itself; we still needed the data to submit properly.</p>
<ol>
<li>After the <acronym title="Document Object Model">DOM</acronym> was ready, loop through all <code>selects</code>. For each <code>select</code>:</li>
<li>Hide the element itself</li>
<li>Append my new markup</li>
<li>Loop through all <code>options</code> for the current <code>select</code> and</li>
<li>Add my own list of options, mirroring those from the original <code>select</code></li>
<li>Bind click events where applicable, making sure to set the proper <code>value</code> on our newly hidden <code>select</code></li>
</ol>
<p>The process seemed straightforward enough, so I began by creating the images I&#8217;d need for the custom <code>select</code>. I began by working with a static version of the enhanced markup (note the addition of a new class, enhanced):</p>
<pre class="sh_html"><code>&lt;form id=&quot;frm_prototype&quot; action=&quot;index.php&quot; method=&quot;post&quot;&gt;
  &lt;fieldset&gt;
    &lt;legend&gt;Custom Select Test&lt;/legend&gt;
    &lt;div class=&quot;enhanced select&quot;&gt;
      &lt;label for=&quot;misc&quot;&gt;Misc&lt;/label&gt;
      &lt;select name=&quot;misc&quot; style=&quot;display:none;&quot;&gt;
          &lt;option value=&quot;1&quot;&gt;One&lt;/option&gt;
          &lt;option value=&quot;2&quot;&gt;Two&lt;/option&gt;
          &lt;option value=&quot;3&quot;&gt;Three&lt;/option&gt;
      &lt;/select&gt;
      &lt;dl class=&quot;dropdown&quot;&gt;
        &lt;dt&gt;&lt;a class=&quot;dropdown_toggle&quot; href=&quot;#&quot;&gt;&lt;span&gt;One&lt;/span&gt;&lt;/a&gt;&lt;/dt&gt;
        &lt;dd&gt;
          &lt;div class=&quot;options&quot;&gt;
            &lt;ul&gt;
              &lt;li&gt;&lt;a href=&quot;#&quot;&gt;One&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Two&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Three&lt;/a&gt;&lt;/li&gt;
            &lt;/ul&gt;
          &lt;/div&gt;
        &lt;/dd&gt;
      &lt;/dl&gt;
    &lt;/div&gt;
    &lt;div class=&quot;buttons&quot;&gt;
      &lt;button type=&quot;submit&quot; id=&quot;submit&quot; name=&quot;submit&quot;&gt;Submit&lt;/button&gt;
    &lt;/div&gt;
  &lt;/fieldset&gt;
&lt;/form&gt;</code></pre>
<p>Some revisions to the CSS, of course (reformatted as multi-line for readability in the article):</p>
<pre class="sh_css"><code>/* Used only when enhanced */

.enhanced a {
	font-size: 11px;
	text-decoration: none;
	color: #7e7e7e;
}

.dropdown {
	float: left;
	width: 200px;
	position: relative;
}

.dropdown .options {
	position: absolute;
	left: 5px;
	top: 23px;
	overflow: auto;
	background: #fff;
	width: 169px;
	height: 55px;
	border: 1px solid #c8c8c8;
	border-top: 0;
	padding: 7px 10px;
}

.dropdown .options ul {
	list-style: none;
}

.dropdown .options a {
	display: block;
	font-size: 12px;
	padding: 2px 0;
}

.dropdown .options a:hover {
	text-decoration: underline;
}

a.dropdown_toggle {
	display: block;
	height: 24px;
	background: url(enhanced-select-arrow.jpg) top right no-repeat;
	padding-right: 25px;
}

a.dropdown_toggle span {
	display: block;
	background: url(enhanced-select-bg.jpg) no-repeat;
	padding: 6px 0 0 8px;
	height: 18px;
	cursor: pointer !important;
}</code></pre>
<p class="single_link"><a href="http://mondaybynoon.com/examples/custom-select/step-2/">View Step 2</a> (note: form submission <em>is not functional</em>)</p>
<h3>Writing the JavaScript</h3>
<p>Now that I had some functional markup and style to use as an endpoint, I began with the fun part, writing the JavaScript. There are a number of other areas on the site using jQuery, my library of choice, so I began by including the library (1.3.2 as of this writing).</p>
<p>I had my mental list of steps to begin taking when progressively enhancing the <code>selects</code>, so I started with step 1: wait for the DOM to load, and then loop through all <code>selects</code>:</p>
<pre class="sh_javascript"><code>$(document).ready(function()
{
  $('select').each(function()
  {
    if(!$(this).parent().hasClass('enhanced'))
    {
      targetselect = $(this);
      targetselect.hide();

      // set our target as the parent and mark as such
      var target = targetselect.parent();
      target.addClass('enhanced');
    }
  }
}</code></pre>
<p>Straightforward enough. That snippet of code uses jQuery&#8217;s document ready event to fire the referenced function once the DOM is ready for us. At this stage, we&#8217;re simply adding our enhanced <code>class</code> if it doesn&#8217;t have the class already. While in the loop, we&#8217;ll go ahead and hide the stock <code>select</code>.</p>
<p>Whenever I work with the same element numerous times, I make an effort to declare it as a variable. It helps to not rely on jQuery looking up the element each and every time and instead finding it once and saving that reference as a variable for future use.</p>
<p>Our next goal is to append the markup we used in Step 2. We&#8217;re not able to include all the markup, as we&#8217;ve only traversed to the <code>select</code> itself thus far, so we&#8217;ll only inject the parent elements we know we&#8217;ll need for now.</p>
<pre class="sh_javascript"><code>// prep the target for our new markup
target.append('&lt;dl class=&quot;dropdown&quot;&gt;&lt;dt&gt;&lt;a class=&quot;dropdown_toggle&quot; href=&quot;#&quot;&gt;&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;&lt;div class=&quot;options&quot;&gt;&lt;ul&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/dd&gt;&lt;/dl&gt;');
target.find('.dropdown').css('zIndex',z);
z--;

// we don't want to see the options yet
target.find('.options').hide();</code></pre>
<p>We&#8217;re also minding the <code>z-index</code> here, as with the creation of each new enhanced <code>select</code>, we&#8217;re going to need to make sure there&#8217;s no improper overlapping. <code>z</code> is a global variable set to 999 at the time of its declaration. With each progressive enhancement, we&#8217;re going to decrement z to ensure proper z-order stacking.</p>
<p>Now we&#8217;ll go ahead and duplicate the <code>options</code> from the original <code>select</code>:</p>
<pre class="sh_javascript"><code>// parse all options within the select and set indices
var i = 0;
var options = '';
targetselect.find('option').each(function()
{
  // add the option
  options += '&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;span class=&quot;value&quot;&gt;' + $(this).text() + '&lt;/span&gt;&lt;span class=&quot;hidden index&quot;&gt;' + i + '&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;';

  // check to see if this is what the default should be
  if($(this).attr('selected') == true)
  {
    targetselect.parent().find('a.dropdown_toggle').append('&lt;span&gt;&lt;/span&gt;').find('span').text($(this).text());
  }
  i++;
});
target.find('.options ul').append(options);</code></pre>
<p>In this snippet, we&#8217;re using our reference variable to find all of the child <code>option</code> elements. For each of those elements, we&#8217;re going to append a list item to the markup we just injected. Through each iteration, we&#8217;re also checking to see which <code>option</code> is currently selected, in order to correctly populate our enhanced <code>select</code>. We also append a second <code>span</code> to each list item to allow the tracking of the <code>option</code> index, we&#8217;ll need this later in order to accurately populate the stock <code>select</code>.</p>
<p>Excellent, now we&#8217;ve got our progressively enhanced select ready to go. The last step will be binding click events in an effort to mimic functionality of the original <code>select</code>.</p>
<h3>Binding click events on our custom select</h3>
<p>The first event we&#8217;ll need to bind is the click event on what we&#8217;ll call the toggle. This is the link we first created, included as a child of the <code>dt</code> element.</p>
<pre class="sh_javascript"><code>// let's hook our links, ya?
$('a.dropdown_toggle').live('click', function()
{
	var theseOptions = $(this).parent().parent().find('.options');
	if(theseOptions.css('display')=='block')
	{
		$('.activedropdown').removeClass('activedropdown');
		theseOptions.hide();
	}
	else
	{
		theseOptions.parent().parent().addClass('activedropdown');
		theseOptions.show();
	}
	return false;
});</code></pre>
<p>The conditional included controls whether or not the associated options list we created earlier is visible or not.</p>
<p>I&#8217;m using a new feature included within jQuery 1.3, the <a href="http://docs.jquery.com/Events/live">live event</a>. It&#8217;s a terrific addition that binds an event for all current <em>and future</em> matched elements. I&#8217;ve elected to use the live event here as there was a possibility for new <code>selects</code> to be created on the fly after the DOM had initially loaded. The live event prevents my having to continually monitor the click events on existing and new toggle links.</p>
<p>Now that the display toggle for our options is in place, we need to also bind to the click events for all of the anchors included in our list of options as well. If any of those anchors are clicked, we need to retrieve the proper value associated with the link, update the toggle link text to reflect the change, and most importantly we need to update the value of the original <code>select</code> that was hidden long ago.</p>
<pre class="sh_javascript"><code>$('.options a').live('click', function(e)
{
	$('.options').hide();

	var enhanced = $(this).parent().parent().parent().parent().parent().parent();
	var realselect = enhanced.find('select');

	// set the proper index
	realselect[0].selectedIndex = $(this).find('span.index').text();

	// update the pseudo selected element
	enhanced.find('.dropdown_toggle').empty().append('&lt;span&gt;&lt;/span&gt;').find('span').text($(this).find('span.value').text());

	return false;
});</code></pre>
<p>Here, we bind to the click event of each child anchor of a parent with a class of &#8216;options&#8217;. Upon click, we&#8217;re going to hide the visible parent (only one will be visible), determine the parent-most element (to which we added the &#8216;enhanced&#8217; class), and find the associated <code>select</code>. Once we&#8217;ve found the select, we can set the proper index to ensure accurate data translation using the hidden <code>span</code> we included in earlier steps. Finally, we&#8217;ll go ahead and update the copy within our enhanced <code>select</code>.</p>
<h3>Done and done? Not quite&#8230;</h3>
<p>The issue with <code>z-index</code> wasn&#8217;t something I initially thought of, it was something I only discovered as I was working. There were a number of additional speed bumps I ran into, which are terribly important as well. As it stood, interaction with the updated <code>select</code> was operating as expected, save for a passive action I originally overlooked. The trouble was with the toggle. In and of itself, the toggle was working as it should, but it was other interaction causing some trouble. For example, if your reader were to toggle open the options of your select, and then move elsewhere in the document without first closing the display of the options by again clicking the toggle, the list would remain in view.</p>
<p>This issue is easy enough to overcome. Prior to finding and looping through all of the <code>selects</code> in the document, you&#8217;ll need to bind to another event:</p>
<pre class="sh_javascript"><code>$(document).mousedown(checkExternalClick);</code></pre>
<p>Binding to the mousedown event for the entire document will fire the <code>checkExternalClick</code> function:</p>
<pre class="sh_javascript"><code>checkExternalClick = function(event)
{
	if ($(event.target).parents('.activedropdown').length === 0)
	{
		$('.activedropdown').removeClass('activedropdown');
		$('.options').hide();
	}
};</code></pre>
<p>What this function does is force any open option lists to hide should the reader click outside our new and improved <code>select</code>. It uses a conditional to check for the <code>class</code> we added during the original toggle, as to not interfere with any other functionality that may have been put in place.</p>
<p class="single_link"><a href="http://mondaybynoon.com/examples/custom-select/step-3/">View Step 3</a> (note: form submission <strong>is functional</strong>)</p>
<p>All together, our JavaScript looks like this:</p>
<pre class="sh_javascript"><code>var z = 999;

checkExternalClick = function(event)
{
  if ($(event.target).parents('.activedropdown').length === 0)
  {
    $('.activedropdown').removeClass('activedropdown');
    $('.options').hide();
  }
};

$(document).ready(function()
{
  $(document).mousedown(checkExternalClick);

  $('select').each(function()
  {
    if(!$(this).parent().hasClass('enhanced'))
    {
      targetselect = $(this);
      targetselect.hide();

      // set our target as the parent and mark as such
      var target = targetselect.parent();
      target.addClass('enhanced');

      // prep the target for our new markup
      target.append('&lt;dl class=&quot;dropdown&quot;&gt;&lt;dt&gt;&lt;a class=&quot;dropdown_toggle&quot; href=&quot;#&quot;&gt;&lt;/a&gt;&lt;/dt&gt;&lt;dd&gt;&lt;div class=&quot;options&quot;&gt;&lt;ul&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/dd&gt;&lt;/dl&gt;');
      target.find('.dropdown').css('zIndex',z);
      z--;

      // we don't want to see it yet
      target.find('.options').hide();

      // parse all options within the select and set indices
      var i = 0;
      targetselect.find('option').each(function()
      {
        // add the option
        target.find('.options ul').append('&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;span class=&quot;value&quot;&gt;' + $(this).text() + '&lt;/span&gt;&lt;span class=&quot;hidden index&quot;&gt;' + i + '&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;');

        // check to see if this is what the default should be
        if($(this).attr('selected') == true)
        {
          targetselect.parent().find('a.dropdown_toggle').append('&lt;span&gt;&lt;/span&gt;').find('span').text($(this).text());
        }
        i++;
      });
    }
  });

  // let's hook our links, ya?
  $('a.dropdown_toggle').live('click', function()
  {
    var theseOptions = $(this).parent().parent().find('.options');
    if(theseOptions.css('display')=='block')
    {
      $('.activedropdown').removeClass('activedropdown');
      theseOptions.hide();
    }
    else
    {
      theseOptions.parent().parent().addClass('activedropdown');
      theseOptions.show();
    }
    return false;
  });

  // bind to clicking a new option value
  $('.options a').live('click', function(e)
  {
    $('.options').hide();

    var enhanced = $(this).parent().parent().parent().parent().parent().parent();
    var realselect = enhanced.find('select');

    // set the proper index
    realselect[0].selectedIndex = $(this).find('span.index').text();

    // update the pseudo selected element
    enhanced.find('.dropdown_toggle').empty().append('&lt;span&gt;&lt;/span&gt;').find('span').text($(this).find('span.value').text());

    return false;
  });
});</code></pre>
<p class="single_link"><a href="http://mondaybynoon.com/examples/custom-select/step-3/">View Step 3</a> (note: form submission <strong>is functional</strong>)</p>
<h3>Almost perfect, but not quite</h3>
<p>I post this example not to propose the best possible solution for progressively enhancing <code>select</code> elements. There are some issues which still need attention, that browser default <code>form</code> widgets better handle out of the box. Such things as rendering the list of <code>options</code> within the viewport should the <code>select</code> be positioned too close to the bottom. We didn&#8217;t cover that scenario, but it&#8217;s something that can be easily overcome using jQuery and a couple conditionals.</p>
<p>While it was great working on a small technique such as this, it really got me thinking about the viability of such a thing. Interface design is a sensitive subject for me, and messing with such standard conventions as browser &amp; operating system interface elements felt wrong on a low level. On the contrary, the stock form widgets shipping with browsers today aren&#8217;t the most gorgeous thing to include in your designs. Would you consider drastically changing the appearance of your <code>form</code> elements?</p>
]]></content:encoded>
			<wfw:commentRss>http://mondaybynoon.com/2009/02/23/creating-custom-form-elements-using-jquery-selects/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Form Design Blunders and Faux Pas on the Web</title>
		<link>http://mondaybynoon.com/2008/07/14/form-design-blunders-and-faux-pas-on-the-web/</link>
		<comments>http://mondaybynoon.com/2008/07/14/form-design-blunders-and-faux-pas-on-the-web/#comments</comments>
		<pubDate>Mon, 14 Jul 2008 12:26:22 +0000</pubDate>
		<dc:creator>Jonathan Christopher</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Opinion]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">http://mondaybynoon.com/?p=141</guid>
		<description><![CDATA[Form design on the Web is an art. There are, however, a number of things which can result in a frustrating experience when interacting with forms. ]]></description>
			<content:encoded><![CDATA[<p>We&#8217;re filling out more forms than ever in our day to day activities. Whether it be sending an update to your favorite social network, a new social network you&#8217;re signing up for, or even sending a message to someone you haven&#8217;t spoken to in 10 years on a social network; forms are being used a lot. All kidding aside, the Web has evolved into a much more participatory environment, and with that come design considerations which may someday result in best practices.</p>
<p>Forms have been viewed as an area of Web design which has much room to improve. From the markup itself to general design guidelines, there are some trends which have evolved surrounding their implementation. Forms may be something you view as a smaller aspect of your overall design, but I&#8217;ve got to be honest when I say that seeing a well designed form is not something I often come across. When I do see a form which has been very well implemented, I try to take some notes to keep in mind for future projects. It&#8217;s difficult for me to express in words what it is that impresses me about well designed forms, but it&#8217;s quite a different story for me to jot down a few things which I find irritating.</p>
<h2>Poor choices for field defaults</h2>
<p>Providing a field default is, in my opinion, usually something that should be avoided. There are certain circumstances where it&#8217;s a necessity, such as using the input itself to reflect what would otherwise be represented by a <code>label</code>. Including a default <code>input</code> <code>value</code> is a significant annoyance if not implemented properly. Always keep in mind that if you are going to provide a field default, make sure you add it with progressive enhancement in mind. I say that because more important is <em>making sure your default is cleared out upon <code>input</code> focus</em>. I can&#8217;t count the times I&#8217;ve gone to enter data in a field with a default value and ended up typing within the default string itself. It&#8217;s a show-stopping event.</p>
<p>Field defaults are in no way limited to text <code>inputs</code> or <code>textareas</code>. A peeve of mine which has developed over the past few months is finding a default entry in a <code>select</code>. For example, stumbling across a form which has a <code>select</code> for the state in which I live. This particular <code>select</code> has a default value of &#8220;(Choose One)&#8221;. Why? The widget itself is designed visually to communicate that there are a number of values to choose from. A <code>select</code> is not an uncommon interaction with a form, why is it necessary? If nothing else, it requires you to apply otherwise unneeded validation on the element. I can possibly understand that it may be used as a method for ensuring the reader has taken the time to choose a value from the <code>select</code>, but to me that&#8217;s a stretch. What&#8217;s worse is seeing &#8220;(Choose One)&#8221; as the default entry with &#8220;Other&#8221; or &#8220;No answer&#8221; as the bottom choice. For <code>selects</code> without required data, why not make &#8220;No answer&#8221; the default?</p>
<p>At the end of the day, if the <code>select</code> is required data, you&#8217;re creating extra work for all parties involved by trying to hook an answer with &#8220;(Please Choose)&#8221;. From the start, you&#8217;re going to need to validate that field. Continuing, if a reader is maliciously trying to submit bunk data, when notified of the required field, an entry will simply be chosen at random, which now looks like a more legitimate answer than &#8220;Other&#8221;.</p>
<p>Another issue I&#8217;d like to bring up with <code>form</code> defaults is one that has to do with <code>radio</code> buttons. Interaction here is very similar to that of <code>selects</code> but in this case, my annoyance happens to be an absence of a default value. The purpose of a series of <code>radio</code> buttons is to have a reader choose one of the available choices. Why leave this section of your form without a default?</p>
<h2>Validation issues</h2>
<p>Form validation is an art form. There are some really fantastic ways to validate forms which not only benefits your server, but also the user experience as well. With the widespread arrival of unobtrusive JavaScript, form validation on the client side has been improved exponentially, but there are still some pitfalls which can result in a very frustrating process for your readers.</p>
<p>Most importantly is being upfront about what data is required when filling out your form. On top of that, you should provide relevant information regarding any syntax required for entering data. Information such as phone numbers, credit card numbers, and dates come to mind. Readers are likely to follow instructions on formatting, and be much happier doing so as opposed to seeing they entered a date wrong because you failed to provide syntax.</p>
<p>A <em>huge peeve</em> of mine when it comes to form validation can only stem from laziness on the part of the developer. It doesn&#8217;t take much to check whether each field was populated already on a page load, so be sure to include the submitted data as a &#8216;default&#8217; <code>value</code> when exercising validation. There&#8217;s nothing worse than taking time to fill out a form only to have the page reload saying I forgot a digit in my phone number, but the rest of my data is missing.</p>
<p>Finally, on the side of form validation, make sure your error notice copy is up to snuff. Ensure the notice is contextual and you&#8217;re not taking the easy way out by dumping the errors at the top of the page, leaving the reader to hunt for information to correct. Make sure each error description is accurate and easy to interpret. If a credit card number was entered incorrectly, do more than classify the data as &#8220;invalid&#8221;. Explain, using syntax if applicable, why the entry does not validate.</p>
<h3>Avoiding general frustrations</h3>
<p>There are number of other issues to consider when designing <code>forms</code>. Something I continue to run into time after time is the classic case of recursive <code>selects</code>. I will <a href="http://mondaybynoon.com/2007/10/01/selects-javascript-and-usability-please-help/">despise this implementation</a> until the end of time. I can understand that it may be a way to de-clutter the <abbr title="User interface">UI</abbr> a bit, but at a serious cost to usability.</p>
<p>Another frustration that often surfaces is poor use of <code>tabindex</code>. Browsers are quite good at figuring out a logical order for <code>tabindex</code> if the developer hasn&#8217;t implemented one, but they&#8217;re not perfect. There are many (high profile) websites with terrible implementations of <code>tabindex</code>, dragging readers here &amp; there in a very disorienting manner. Issues with <code>form</code> jumping can be easily avoided with a quick <a href="http://mondaybynoon.com/2006/10/09/helping-your-user-with-tabindex/">implementation of a logical <code>tabindex</code></a>.</p>
<p>I know I&#8217;m not alone when I say I&#8217;ve got a few annoyances when interacting with forms on a daily basis. What is it that truly bothers you about poor <code>form</code> design? What tricks do you have up your sleeve which have worked out really well in practice?</p>
]]></content:encoded>
			<wfw:commentRss>http://mondaybynoon.com/2008/07/14/form-design-blunders-and-faux-pas-on-the-web/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk (enhanced) (user agent is rejected)
Database Caching 6/15 queries in 0.009 seconds using disk

Served from: mondaybynoon.com @ 2010-09-09 12:46:28 -->