<?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>TJ Koblentz</title>
	<atom:link href="http://www.tjkoblentz.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tjkoblentz.com</link>
	<description>Random things.</description>
	<lastBuildDate>Sun, 10 Jan 2010 22:57:37 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Semantic form feedback</title>
		<link>http://www.tjkoblentz.com/2010/01/10/semantic-form-feedback/</link>
		<comments>http://www.tjkoblentz.com/2010/01/10/semantic-form-feedback/#comments</comments>
		<pubDate>Sun, 10 Jan 2010 22:57:37 +0000</pubDate>
		<dc:creator>TJ</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[semantic]]></category>

		<guid isPermaLink="false">http://www.tjkoblentz.com/?p=122</guid>
		<description><![CDATA[I recently coded up a contact form from scratch with some valid HTML 4.01, PHP, and jQuery for a website my dad has been working on a came out with one pretty basic, yet very important tidbit of information regarding semantics.


No related posts.]]></description>
			<content:encoded><![CDATA[<p>I recently coded up a contact form from scratch with some valid HTML 4.01, PHP, and jQuery for a website my dad has been working on and came out of the &#8216;exercise&#8217; with one basic, yet very important tidbit of information regarding semantics.</p>
<p>When using Javascript to give on-the-fly feedback to the user, one may be tempted to do something like:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// with jQuery for legibility and beautifulness</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#some-input-field&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;blur&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> text <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'value'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>    
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>is_valid<span style="color: #009900;">&#40;</span>text<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">// greenish background / border to tell user input value is valid</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
      <span style="color: #3366CC;">'background'</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">'#BFFEBF'</span><span style="color: #339933;">,</span>
      <span style="color: #3366CC;">'border'</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">'1px solid #00EE00'</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">// red colors signify invalid input value</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
      <span style="color: #3366CC;">'background'</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">'#FEBFBF'</span><span style="color: #339933;">,</span>
      <span style="color: #3366CC;">'border'</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">'1px solid #EE0000'</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Don&#8217;t. CSS should not do anything more than provide styling. Using CSS to give the user feedback is not the right method of doing things. Rather, one should add / remove classes which themselves can be targeted with CSS. This way, the underlying response the Javascript provides are <a href="http://www.w3.org/QA/Tips/goodclassnames">semantic class names</a>. Even if styling is removed, the HTML has meaning.</p>
<p>So, to finish, replace the above code with something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">// CSS
<span style="color: #6666ff;">.valid</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span> <span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#BFFEBF</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">border</span> <span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#00EE00</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.error</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span> <span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#FEBFBF</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">border</span> <span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#EE0000</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// jQuery</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#some-input-field&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;blur&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> text <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'value'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>    
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>is_valid<span style="color: #009900;">&#40;</span>text<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;error&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;valid&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;valid&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;error&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>



<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.tjkoblentz.com/2010/01/10/semantic-form-feedback/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hello World</title>
		<link>http://www.tjkoblentz.com/2009/12/11/hello-world/</link>
		<comments>http://www.tjkoblentz.com/2009/12/11/hello-world/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 07:56:13 +0000</pubDate>
		<dc:creator>TJ</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.tjkoblentz.com/?p=71</guid>
		<description><![CDATA[The site just went live (for the third time). Just checking in to say hi.


No related posts.


No related posts.]]></description>
			<content:encoded><![CDATA[<p>The site just went live (for the third time). Just checking in to say hi.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.tjkoblentz.com/2009/12/11/hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
