<?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>devness &#187; upper case</title>
	<atom:link href="http://devness.com/tag/upper-case/feed/" rel="self" type="application/rss+xml" />
	<link>http://devness.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Wed, 01 Jul 2009 21:41:37 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Forcing Letter Case with CSS and jQuery</title>
		<link>http://devness.com/2009/06/forcing-letter-case-with-css-and-jquery/</link>
		<comments>http://devness.com/2009/06/forcing-letter-case-with-css-and-jquery/#comments</comments>
		<pubDate>Tue, 16 Jun 2009 21:49:33 +0000</pubDate>
		<dc:creator>dmoena</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[force letter case]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[lower case]]></category>
		<category><![CDATA[upper case]]></category>

		<guid isPermaLink="false">http://devness.com/?p=45</guid>
		<description><![CDATA[
.upper {text-transform:uppercase;} .lower {text-transform:lowercase;} 
Try this two forms. Both force letter case, but only one of them will send to the server exactly what you see (in terms of lower and upper case).










See? Now, let me explain what just happen and how to avoid the first situation.

Explanation
In each form we just force letter casing by [...]]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript" src="http://devness.com/wp-content/uploads/2009/06/casingdemo.js"></script></p>
<style>.upper {text-transform:uppercase;} .lower {text-transform:lowercase;} </style>
<p>Try this two forms. Both force letter case, but only one of them will send to the server exactly what you see (in terms of lower and upper case).</p>
<form id="nocaseform">
<input type="text" class="upper" name="upper"/>
<input type="text" class="lower" name="lower"/>
<input type="submit" value="Non-cased Form"/>
</form>
<form id="caseform">
<input type="text" class="upper" name="upper"/>
<input type="text" class="lower" name="lower"/>
<input type="submit" value="Cased Form"/>
</form>
<p>See? Now, let me explain what just happen and how to avoid the first situation.</p>
<p><span id="more-45"></span></p>
<h2>Explanation</h2>
<p>In each form we just force letter casing by using CSS. In this case, inputs with the &#8220;upper&#8221; class will be upper cased and those with the &#8220;lower&#8221; class will be lower cased.</p>
<div class="codesnip-container" >
<div class="codesnip" style="font-family: monospace;"><span class="re1">.upper</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; text-transform<span class="re2">:uppercase</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="re1">.lower</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; text-transform<span class="re2">:lowercase</span>;<br />
<span class="br0">&#125;</span></div>
</div>
<p>The problem is that we get only the impression of lower and/or upper case, but we will actually send data cased as the user has entered. This means that even when you see &#8220;ABCD&#8221; you could actually receive &#8220;aBCd&#8221; at the server. I know, is not a big deal since you can (and should) force casing at server side, but sometimes you just want to be sure that your data is sent with the propper format.</p>
<h2>A solution</h2>
<p>So, how to solve this? jQuery (jQuery makes this easier, but you can use plain JavaScript too). You just need to add this code (plus the previous CSS one) to intercept any form submit, force propper and effective data casing and then continue with the sumbit process.</p>
<div class="codesnip-container" >
<div class="codesnip" style="font-family: monospace;">&lt;script type=<span class="st0">&quot;text/javascript&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; $<span class="br0">&#40;</span>document<span class="br0">&#41;</span>.<span class="me1">ready</span><span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span class="br0">&#40;</span><span class="st0">&quot;form&quot;</span><span class="br0">&#41;</span>.<span class="me1">submit</span><span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span class="br0">&#40;</span><span class="kw1">this</span><span class="br0">&#41;</span>.<span class="me1">find</span><span class="br0">&#40;</span><span class="st0">&quot;.upper&quot;</span><span class="br0">&#41;</span>.<span class="me1">each</span><span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span class="br0">&#40;</span><span class="kw1">this</span><span class="br0">&#41;</span>.<span class="me1">val</span><span class="br0">&#40;</span>String<span class="br0">&#40;</span>$<span class="br0">&#40;</span><span class="kw1">this</span><span class="br0">&#41;</span>.<span class="me1">val</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>.<span class="me1">toUpperCase</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><span class="br0">&#41;</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span class="br0">&#40;</span><span class="kw1">this</span><span class="br0">&#41;</span>.<span class="me1">find</span><span class="br0">&#40;</span><span class="st0">&quot;.lower&quot;</span><span class="br0">&#41;</span>.<span class="me1">each</span><span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span class="br0">&#40;</span><span class="kw1">this</span><span class="br0">&#41;</span>.<span class="me1">val</span><span class="br0">&#40;</span>String<span class="br0">&#40;</span>$<span class="br0">&#40;</span><span class="kw1">this</span><span class="br0">&#41;</span>.<span class="me1">val</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>.<span class="me1">toLowerCase</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><span class="br0">&#41;</span>;<br />
&lt;/script&gt;</div>
</div>
<p>Simple, but useful in case you are working with casing.</p>
]]></content:encoded>
			<wfw:commentRss>http://devness.com/2009/06/forcing-letter-case-with-css-and-jquery/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
