<?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>zParacha.com &#187; Javascript</title>
	<atom:link href="http://www.zparacha.com/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zparacha.com</link>
	<description>Effective programming and blogging tips by Zaheer Paracha</description>
	<lastBuildDate>Wed, 09 Nov 2011 00:52:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Why you should stop using onload method.</title>
		<link>http://www.zparacha.com/better-alternative-to-onload/</link>
		<comments>http://www.zparacha.com/better-alternative-to-onload/#comments</comments>
		<pubDate>Tue, 02 Feb 2010 03:46:27 +0000</pubDate>
		<dc:creator>Zaheer Paracha</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[focus]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[JS]]></category>
		<category><![CDATA[onload]]></category>

		<guid isPermaLink="false">http://www.zparacha.com/?p=1127</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/better-alternative-to-onload/' addthis:title='Why you should stop using onload method.' ><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a></div>It is amazing that many web developers still use onload method embedded in the BODY tag, like &#60;HEAD&#62; &#60;BODY onload="document.contact.userID.focus();"&#62; &#60;form name="contact"&#62; &#60;input type="text" name="userID" &#62; &#60;/form&#62; &#60;/BODY&#62; &#60;/HEAD&#62; There are two problems with this line of code. Embedding code (behavior) with HTML (structure) makes it difficult to maintain the page. onload() method will executes [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/better-alternative-to-onload/' addthis:title='Why you should stop using onload method.' ><a class="addthis_button_googlereader"></a><a class="addthis_button_email"></a><a class="addthis_button_google"></a><a class="addthis_button_twitter"></a><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a><a class="addthis_button_compact"></a></div><p><a href="http://www.zparacha.com/better-alternative-to-onload/">Why you should stop using onload method.</a> is a post from: <a href="http://www.zparacha.com">zParacha.com | Effective programming and blogging tips by Zaheer Paracha</a></p>



<span style="font-weight:bold;"> Related posts:</span><ul><li><a href='http://www.zparacha.com/textfield_focus/' rel='bookmark' title='Permanent Link: Set focus on the first text field of HTML form.'>Set focus on the first text field of HTML form.</a> <small>A HTML form is a very good channel that you...</small></li>
<li><a href='http://www.zparacha.com/css-text-resize/' rel='bookmark' title='Permanent Link: Dynamically Resize Text'>Dynamically Resize Text</a> <small>.codeText{color:blue;font-weight:normal;width:100%;} .subhead{color:gray;font-weight:bold;text-decoration:underline;} CSS, combined with little JavaScript, offers great flexibility...</small></li>
<li><a href='http://www.zparacha.com/ajax-contact-from/' rel='bookmark' title='Permanent Link: AJAX Contact Form'>AJAX Contact Form</a> <small>Want to collect input from your web site&#8217;s visitors? Don&#8217;t...</small></li>
</ul>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/better-alternative-to-onload/' addthis:title='Why you should stop using onload method.' ><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a></div><div id="attachment_1152" class="wp-caption alignleft" style="width: 286px"><a href="http://www.zparacha.com/better-alternative-to-onload/onload-2/" rel="attachment wp-att-1152"><img src="http://www.zparacha.com/wp-content/uploads/2010/02/onload1-276x300.png" alt="onload1 276x300 Why you should stop using onload method." title="onload" width="276" height="300" class="size-medium wp-image-1152" /></a><p class="wp-caption-text">Onload</p></div>
<p>It is amazing that many web developers still use onload method embedded in the BODY tag, like</p>
<pre><code>
 &lt;HEAD&gt;
 &lt;BODY onload="document.contact.userID.focus();"&gt;
  &lt;form name="contact"&gt;
   &lt;input type="text" name="userID" &gt;
  &lt;/form&gt;
  &lt;/BODY&gt;
 &lt;/HEAD&gt;
</code></pre>
<p>There are two problems with this line of code. </p>
<ol>
<li>
Embedding code (behavior) with HTML (structure) makes it difficult to maintain the page.</li>
<li>onload() method will executes only after the page is fully displayed.</li>
</ul>
<p>Let&#8217;s see how to fix these problems.<span id="more-1127"></span><br />
Fixing problem # is quite simple. Just move your JavaScript code to the header section of you HTML page.</p>
<pre><code>
&lt;HTML&gt;
&lt;HEAD&gt;
&lt;script language="javascript"&gt;
function setFocus(){
	document.contact.userID.focus();
}
&lt;/script&gt;
&lt;/HEAD&gt;
&lt;BODY onload="setFocus();"&gt;
&lt;form name="contact"&gt;
&lt;input type="text" name="userID" &gt;
&lt;/form&gt;
&lt;/BODY>
&lt;/HTML&gt;
</pre>
<p></code></p>
<p>Even better approach would be to move the code to an external Javascript file and add a reference to that file in the header section of the HTML document. For example, if the code is in script.js you can import the code like</p>
<pre><code>
&lt;HTML&gt;
&lt;HEAD&gt;&lt;script language="javascript" ref="scripts/script.js"&gt;
&lt;/HEAD&gt;
&lt;BODY onload="setFocus();"&gt;
&lt;form name="contact"&gt;
&lt;input type="text" name="userID" &gt;
&lt;/form&gt;
&lt;/BODY>&lt;
/HTML&gt;
</code></pre>
<p><!--adsense#greyLeft--></p>
<p>This approach will make your HTML code clutter-free and the code will be more manageable. But this does not address the fact the there is a delay in the exectuion of the code. onload method executes after the page is completely loaded.  For instance, if you want to set focus to a text field on your web page using onload method, the foucs will be set after the page is completly downloaded.</p>
<p>If your web page is a simple text page with no images or multimedia elements then using onload might be OK. However, nowadays almost all web pages have at least few images, some even have embedded audio, video, Flash or other rich multimedia resources. These large resources take considerably long time to be fully loaded. And until all the content of the page is fully downloaded and the DOM tree is constructed, onload will not be fired. </p>
<h3>Set focus to the text field without onload:</h3>
<p>There is nothing wrong with the onload method, the problem is the large size of page elements that need to be downloaded by the browser. The browser needs to construct the DOM tree, load all the images and other multi-media resources and when everything is done then it will execute the onload method. A DOM tree is constructed instantly by the browser, but the large size of other elements take a while to be fully loaded. It means these external multilmedia files keep browser from executing the code triggred my onload event. The best approach would be to wait just long enough to let browser contstuct the DOM tree and then execute your code without waiting for all the objects to be completely downloaded. This can be done by using jQuery's <b>ready()</b> function.</p>
<pre><code>
  &lt;script type="text/javascript" src="scripts/jquery-1.3.2.min.js"&gt;
  &lt;/script&gt;
    &lt;script type="text/javascript"&gt;
      jQuery(document).ready(function() {
        document.contact.userID.focus();
      });
    &lt;/script&gt;
</code></pre>
<p>or more formally.</p>
<pre><code>
$(function(){
	document.contact.userID.focus();
}
</code></pre>
<p>So now your HTML code will be like</p>
<pre><code>
 &lt;HTML&gt;
 &lt;HEAD&gt;
  &lt;script type="text/javascript" src="scripts/jquery-1.3.2.min.js"&gt;
  &lt;/script&gt;
    &lt;script type="text/javascript"&gt;
      jQuery(document).ready(function() {
        document.contact.userID.focus();
      });
    &lt;/script&gt;
 &lt;/HEAD&gt;
 &lt;BODY &gt;
 &lt;form name="contact"&gt;
 &lt;input type="text" name="userID" &gt;
 &lt;/form&gt;
 &lt;/BODY>
 &lt;/HTML&gt;
</pre>
<p></code></p>
<p>Now our JavaScript code will be executed as soon as the DOM is fully constructed, without waiting for images and other multimedia resources. In this example the focus will be set to your input text field almost instantly and user can start typing in the information without waiting for rest of the page to be downloaded. This is a simple but effective way of improving your website's usability. </p>
<p><!--adsense#tla-->
<div class="tweetmeme_button" style="float:right; margin: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.zparacha.com%2Fbetter-alternative-to-onload%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.zparacha.com%2Fbetter-alternative-to-onload%2F&amp;source=zparacha&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" title="Why you should stop using onload method." alt=" Why you should stop using onload method." /><br />
			</a>
		</div>
<p><a href="http://www.zparacha.com/better-alternative-to-onload/">Why you should stop using onload method.</a> is a post from: <a href="http://www.zparacha.com">zParacha.com | Effective programming and blogging tips by Zaheer Paracha</a></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Why you should stop using onload method. on zParacha.com: Effective Programming tips',url: 'http://www.zparacha.com/better-alternative-to-onload/',contentID: 'post-1127',signature: 'If you enjoyed this post, make sure you subscribe to my &lt;a href=\&quot;http://www.zparacha.com/feed/\&quot;&gt; RSS feed&lt;/a&gt;.',suggestTags: 'focus,Javascript,jQuery,JS,onload',providerName: 'zParacha.com: Effective Programming tips',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-vert.png" class="evernoteSiteMemoryButton" title="Why you should stop using onload method." alt="article clipper vert Why you should stop using onload method." />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/better-alternative-to-onload/' addthis:title='Why you should stop using onload method.' ><a class="addthis_button_googlereader"></a><a class="addthis_button_email"></a><a class="addthis_button_google"></a><a class="addthis_button_twitter"></a><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a><a class="addthis_button_compact"></a></div>

<p><span style="font-weight:bold;"> Related posts:</span><ul><li><a href='http://www.zparacha.com/textfield_focus/' rel='bookmark' title='Permanent Link: Set focus on the first text field of HTML form.'>Set focus on the first text field of HTML form.</a> <small>A HTML form is a very good channel that you...</small></li>
<li><a href='http://www.zparacha.com/css-text-resize/' rel='bookmark' title='Permanent Link: Dynamically Resize Text'>Dynamically Resize Text</a> <small>.codeText{color:blue;font-weight:normal;width:100%;} .subhead{color:gray;font-weight:bold;text-decoration:underline;} CSS, combined with little JavaScript, offers great flexibility...</small></li>
<li><a href='http://www.zparacha.com/ajax-contact-from/' rel='bookmark' title='Permanent Link: AJAX Contact Form'>AJAX Contact Form</a> <small>Want to collect input from your web site&#8217;s visitors? Don&#8217;t...</small></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://www.zparacha.com/better-alternative-to-onload/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Nine Must Have JavaScript Tools For Every Web Developer</title>
		<link>http://www.zparacha.com/javascript-tools-web-developers/</link>
		<comments>http://www.zparacha.com/javascript-tools-web-developers/#comments</comments>
		<pubDate>Fri, 16 Oct 2009 01:20:35 +0000</pubDate>
		<dc:creator>Zaheer Paracha</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[damnit]]></category>
		<category><![CDATA[firebug]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[javascript frameworks]]></category>
		<category><![CDATA[javascript tools]]></category>
		<category><![CDATA[javascriptmvc]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[web development tools]]></category>

		<guid isPermaLink="false">http://www.zparacha.com/?p=541</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/javascript-tools-web-developers/' addthis:title='Nine Must Have JavaScript Tools For Every Web Developer' ><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a></div>Almost all major web development projects include some javascript. Developing Javascript may be easy for some but working around various browsers&#8217; incompatiblities makes it a bit more tedious chore. As a developer I always welcome the opportunity to use development tools that may help in the development process. Following is a list of some useful [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/javascript-tools-web-developers/' addthis:title='Nine Must Have JavaScript Tools For Every Web Developer' ><a class="addthis_button_googlereader"></a><a class="addthis_button_email"></a><a class="addthis_button_google"></a><a class="addthis_button_twitter"></a><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a><a class="addthis_button_compact"></a></div><p><a href="http://www.zparacha.com/javascript-tools-web-developers/">Nine Must Have JavaScript Tools For Every Web Developer</a> is a post from: <a href="http://www.zparacha.com">zParacha.com | Effective programming and blogging tips by Zaheer Paracha</a></p>



<span style="font-weight:bold;"> Related posts:</span><ul><li><a href='http://www.zparacha.com/top-10-tools-for-bloggers/' rel='bookmark' title='Permanent Link: Top 10 tools for bloggers.'>Top 10 tools for bloggers.</a> <small>If you are looking for ways to improve your blogging...</small></li>
<li><a href='http://www.zparacha.com/compress-js-css/' rel='bookmark' title='Permanent Link: Compress JavaScript and CSS files to optimize website speed.'>Compress JavaScript and CSS files to optimize website speed.</a> <small>Referencing external JavaScript and/or CSS files from a web page...</small></li>
<li><a href='http://www.zparacha.com/improve_javascript_code/' rel='bookmark' title='Permanent Link: Improve your JavaScript code.'>Improve your JavaScript code.</a> <small>Christian Heilmann compiled a list of seven rules for unobtrusive...</small></li>
</ul>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/javascript-tools-web-developers/' addthis:title='Nine Must Have JavaScript Tools For Every Web Developer' ><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a></div><p>Almost all major web development projects include some javascript. Developing Javascript may be easy for some but working around various browsers&#8217; incompatiblities makes it a bit more tedious chore. As a developer I always welcome the opportunity to use development tools that may help in the development process. Following  is a list of some useful <a id="aptureLink_lcc0uqSPnO" href="http://en.wikipedia.org/wiki/JavaScript">Javascript </a>tools that I believe every web programmer should have at his or her disposal.<br />
<span id="more-541"></span><br />
<!--adsense#tla-->
<ul>
<li>
<h4>Javascript Frameworks:</h4>
</li>
<h4><a href="http://www.extjs.com/products/extjs/">Ext JS</a></h4>
<p> ExtJS is a client-side, JavaScript framework for building rich web applications. </p>
<blockquote><p>Ext JS is a cross-browser JavaScript library for building rich internet applications. It includes:</p>
<p>    * High performance, customizable UI widgets<br />
    * Well designed and extensible Component model<br />
    * An intuitive, easy to use API
	</p></blockquote>
<p>Ext JS supports all major web browsers.</p>
<h4><a href="http://www.sproutcore.com">SproutCore</a></h4>
<p>SproutCore is another Javascript framework for developing thick-client web applications in JavaScript. The development team of this cross-browser framework claims that their SproutCore offers best performance for web applications. They have incorporated <a href="http://stevesouders.com/">Steve Souders&#8217;</a>  recommendations for building high performance websites into the framework that makes any web appliacation developed with this framwork perform much better.</p>
<h4>
<a href="http://javascriptmvc.com/">JavaScriptMVC</a></h4>
<p> As the name implies the JavaScriptMVC framework is based on the popular Model-View-Controller (MVC) software architecture. The framework is built using jQuery and offers best practices in software development making it easy to develop and maintain the code for a large project. </p>
<blockquote><p>
JavascriptMVC is an open source framework that incorporates software-development best practices in javascript code. It guides you to successfully completed projects by promoting best practices, maintainability, and convention over configuration.</p></blockquote>
<li>
<h3>Documentation:</h3>
<p>I know how much all developers love the documentation part of a project. But documentation is an integral part of software development, to ease the pain of the documenation you can use  JSDoc Toolkit.</p>
<h4> <a href="http://code.google.com/p/jsdoc-toolkit/">JsDoc Toolkit</a></h4>
<p> Similar to Javadoc, that creates documentation from Java comments, JsDoc can generate documentation from comments in Javascript source code. </p>
<blockquote><p>Jsdoc-Toolkit is an application, written in JavaScript, for automatically generating template-formatted, multi-page HTML (or XML, JSON, or any other text-based) documentation from commented JavaScript source code.</p></blockquote>
</li>
<li>
<h3>Image Manipulation</h3>
<p><!--adsense#greyRight--></p>
<h4><a href="http://www.pixastic.com/">Pixastic</a></h4>
<p> If you need to do image manipulation in your web application Pixastic mya help you. Pixastic is a JavaScript library which allows you to perform a variety of operations, filters and fancy effects on images using just a bit of JavaScript.<br />
&#8220;Pixastic is an experimental library which allows you to perform a variety of operations on images using just a bit of JavaScript. The effects supported out of the box include desaturation/greyscale, invert, flipping, brightness/contrast adjustment, hue/saturation, emboss, blur, and many more. For the full list, see the documentation page.&#8221;</p>
<p>Pixastic works by utilizing HTML5 Canvas elemtent, so it does not work well with IE that does not support Canvas.</p>
</li>
<li>
<h3>Debugging</h3>
<h4>
<a href="http://www.firebug.com"/>Firebug</a></h4>
<p>: Firebug is my favorite debugging tool for Javascript based web applications. It is feature riched JavaScript debugging tool.</p>
<blockquote><p>Firebug integrates with Firefox to put a wealth of web development tools at your fingertips while you browse. You can edit, debug, and monitor CSS, HTML, and JavaScript live in any web page.
</p></blockquote>
<h4><a href="https://damnit.jupiterit.com/">DamnIT</a></h4>
<p>You can debug your web application only that much. With several different browsers you can never be sure that you have caught and fixed all the bugs in your Javascript code. This is where <a href="https://damnit.jupiterit.com/">DamnIT</a> can help. DamnIT is a  Javascript error reporting service that can email you detailed error report when a user encounters a Javascript error on your website. It is a free service which can be really useful for debugging large web applications.
</li>
<li>
<h3>Javascript Widgets</h3>
<h4><a href="http://livepipe.net/">LivePipe</a></h4>
<p>LivePipe UI is a suite of high quality widgets and controls for web 2.0 applications. It is built using the Prototype JavaScript Framework. Each control is well tested, highly extensible, fully documented and degrades gracefully for non JavaScript enabled browsers where possible. MIT licensed and actively maintained. It employs event oriented programming concepts that introduces a mechanism to create and observe events on any object, not just DOM elements. This is used by all controls, and allows for fine grained control of your user interface.</p>
<h4><a href="http://digitarald.de/project/roar/">Roar-Notifications</a></h4>
<p> Have you ever visited a website that displays pop-up alerts reminding you of their services? Those pop-up alerts of the past were annoyning and I don&#8217;t encounter them anymore. But sometimes there is a legitimate reason to display some information to your websitev visitors without innterupting their browsing pleasure. <a href="http://digitarald.de/project/roar/">Roar</a> widget is the alternative to those annoying pop-up alerts. This Javascript widget (worked with MooTool Javascript) allows you to display your messages in an unobtrusive way. You can customize the appearance of the widget and control the positions of the messages. The messages are interactive, user can click them to visit other pages on your website or hover over them to read them at their own pace. </p>
</ul>
<p>Have you used any of these tools? Do you have your favorite Javascript tool?<br />
<br/></p>
<div class="tweetmeme_button" style="float:right; margin: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.zparacha.com%2Fjavascript-tools-web-developers%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.zparacha.com%2Fjavascript-tools-web-developers%2F&amp;source=zparacha&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" title="Nine Must Have JavaScript Tools For Every Web Developer" alt=" Nine Must Have JavaScript Tools For Every Web Developer" /><br />
			</a>
		</div>
<p><a href="http://www.zparacha.com/javascript-tools-web-developers/">Nine Must Have JavaScript Tools For Every Web Developer</a> is a post from: <a href="http://www.zparacha.com">zParacha.com | Effective programming and blogging tips by Zaheer Paracha</a></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Nine Must Have JavaScript Tools For Every Web Developer on zParacha.com: Effective Programming tips',url: 'http://www.zparacha.com/javascript-tools-web-developers/',contentID: 'post-541',signature: 'If you enjoyed this post, make sure you subscribe to my &lt;a href=\&quot;http://www.zparacha.com/feed/\&quot;&gt; RSS feed&lt;/a&gt;.',suggestTags: 'damnit,firebug,framework,Javascript,javascript frameworks,javascript tools,javascriptmvc,tools,web development tools',providerName: 'zParacha.com: Effective Programming tips',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-vert.png" class="evernoteSiteMemoryButton" title="Nine Must Have JavaScript Tools For Every Web Developer" alt="article clipper vert Nine Must Have JavaScript Tools For Every Web Developer" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/javascript-tools-web-developers/' addthis:title='Nine Must Have JavaScript Tools For Every Web Developer' ><a class="addthis_button_googlereader"></a><a class="addthis_button_email"></a><a class="addthis_button_google"></a><a class="addthis_button_twitter"></a><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a><a class="addthis_button_compact"></a></div>

<p><span style="font-weight:bold;"> Related posts:</span><ul><li><a href='http://www.zparacha.com/top-10-tools-for-bloggers/' rel='bookmark' title='Permanent Link: Top 10 tools for bloggers.'>Top 10 tools for bloggers.</a> <small>If you are looking for ways to improve your blogging...</small></li>
<li><a href='http://www.zparacha.com/compress-js-css/' rel='bookmark' title='Permanent Link: Compress JavaScript and CSS files to optimize website speed.'>Compress JavaScript and CSS files to optimize website speed.</a> <small>Referencing external JavaScript and/or CSS files from a web page...</small></li>
<li><a href='http://www.zparacha.com/improve_javascript_code/' rel='bookmark' title='Permanent Link: Improve your JavaScript code.'>Improve your JavaScript code.</a> <small>Christian Heilmann compiled a list of seven rules for unobtrusive...</small></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://www.zparacha.com/javascript-tools-web-developers/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to display RSS feed on your website.</title>
		<link>http://www.zparacha.com/display-rss-feed-website/</link>
		<comments>http://www.zparacha.com/display-rss-feed-website/#comments</comments>
		<pubDate>Wed, 21 Jan 2009 05:05:11 +0000</pubDate>
		<dc:creator>Zaheer</dc:creator>
				<category><![CDATA[Blogging]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[rss feeds]]></category>

		<guid isPermaLink="false">http://www.zparacha.com/?p=281</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/display-rss-feed-website/' addthis:title='How to display RSS feed on your website.' ><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a></div>Image credit:Kyle Wegner OK, admit this. You have a nice-looking website. The color and the graphics look pleasing to visiting eyes. But you do not get a lot of loyal visitors. The problem may not be your design, it may be the static content that is turning the visitors off. If you do not update [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/display-rss-feed-website/' addthis:title='How to display RSS feed on your website.' ><a class="addthis_button_googlereader"></a><a class="addthis_button_email"></a><a class="addthis_button_google"></a><a class="addthis_button_twitter"></a><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a><a class="addthis_button_compact"></a></div><p><a href="http://www.zparacha.com/display-rss-feed-website/">How to display RSS feed on your website.</a> is a post from: <a href="http://www.zparacha.com">zParacha.com | Effective programming and blogging tips by Zaheer Paracha</a></p>



<span style="font-weight:bold;"> Related posts:</span><ul><li><a href='http://www.zparacha.com/rss_feed_api/' rel='bookmark' title='Permanent Link: Display external RSS feeds on your website.'>Display external RSS feeds on your website.</a> <small>You have designed a beautiful website. But you still do...</small></li>
<li><a href='http://www.zparacha.com/compress-js-css/' rel='bookmark' title='Permanent Link: Compress JavaScript and CSS files to optimize website speed.'>Compress JavaScript and CSS files to optimize website speed.</a> <small>Referencing external JavaScript and/or CSS files from a web page...</small></li>
<li><a href='http://www.zparacha.com/mobilize-website/' rel='bookmark' title='Permanent Link: Mobilize your website'>Mobilize your website</a> <small>Did you know that there are approximately 1.5 billion mobile...</small></li>
</ul>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/display-rss-feed-website/' addthis:title='How to display RSS feed on your website.' ><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a></div><p style="text-align: center; display: inline; width: 250px; font-size: 10px; text-decoration: none" class="alignright">  <img src="http://www.zparacha.com/images/rss_m.jpg" alt="rss m How to display RSS feed on your website." class="alignright" style="border:none;" title="How to display RSS feed on your website." /><br />
Image credit:<a href="http://www.flickr.com/photos/14589496@N05/2371165319/sizes/s/" target="_blank" style="text-decoration:none;">Kyle Wegner</a></p>
<p>OK, admit this. You have a nice-looking website. The color and the graphics look pleasing<br />
to visiting eyes. But you do not get a lot of loyal visitors. The problem may not be your design,<br />
it may be the static content that is turning the visitors off. If you do not update your website regularly, you may not attract enough repeat visitors. One way to juice up your website is to display RSS feeds from other relevant and reputable websites. Don&#8217;t know how to incorporate the RSS feeds into your website? Here is what you need:<span id="more-281"></span></p>
<div class="alignleft"><!--adsense#green1--></div>
<p>All you need is some basic JavaScript knowledge. In fact, you don&#8217;t even need that if you know how to cut &#038; paste and which files to update. Yes it is that easy and thanks Google for this convenience. What was once considered a tedious task, Google made it super duper easy. Google developed an AJAX based API that you can call from a JavaScript method.</p>
<p>The API returns the content of the RSS feed that you specify. And then you can display that content on your own web site.</p>
<p>You can visit <a href="http://www.javascriptkit.com/dhtmltutors/googleajaxfeed.shtml"> Javascrip Kit</a> for a detailed explanation of Google API.<br />
There you will also find some easy-to-follow examples that you can use on your website. Just change the feed URL in the JavaScript to the ones that you want to display on your website.</p>
<p>For official documentation and examples from Google visit <a href="http://code.google.com/apis/ajaxfeeds/">Google APIs page</a> page.<br />
Enjoy!<br />
<!--adsense#tla--></p>
<div class="tweetmeme_button" style="float:right; margin: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.zparacha.com%2Fdisplay-rss-feed-website%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.zparacha.com%2Fdisplay-rss-feed-website%2F&amp;source=zparacha&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" title="How to display RSS feed on your website." alt=" How to display RSS feed on your website." /><br />
			</a>
		</div>
<p><a href="http://www.zparacha.com/display-rss-feed-website/">How to display RSS feed on your website.</a> is a post from: <a href="http://www.zparacha.com">zParacha.com | Effective programming and blogging tips by Zaheer Paracha</a></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'How to display RSS feed on your website. on zParacha.com: Effective Programming tips',url: 'http://www.zparacha.com/display-rss-feed-website/',contentID: 'post-281',signature: 'If you enjoyed this post, make sure you subscribe to my &lt;a href=\&quot;http://www.zparacha.com/feed/\&quot;&gt; RSS feed&lt;/a&gt;.',suggestTags: 'Javascript,rss feeds',providerName: 'zParacha.com: Effective Programming tips',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-vert.png" class="evernoteSiteMemoryButton" title="How to display RSS feed on your website." alt="article clipper vert How to display RSS feed on your website." />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/display-rss-feed-website/' addthis:title='How to display RSS feed on your website.' ><a class="addthis_button_googlereader"></a><a class="addthis_button_email"></a><a class="addthis_button_google"></a><a class="addthis_button_twitter"></a><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a><a class="addthis_button_compact"></a></div>

<p><span style="font-weight:bold;"> Related posts:</span><ul><li><a href='http://www.zparacha.com/rss_feed_api/' rel='bookmark' title='Permanent Link: Display external RSS feeds on your website.'>Display external RSS feeds on your website.</a> <small>You have designed a beautiful website. But you still do...</small></li>
<li><a href='http://www.zparacha.com/compress-js-css/' rel='bookmark' title='Permanent Link: Compress JavaScript and CSS files to optimize website speed.'>Compress JavaScript and CSS files to optimize website speed.</a> <small>Referencing external JavaScript and/or CSS files from a web page...</small></li>
<li><a href='http://www.zparacha.com/mobilize-website/' rel='bookmark' title='Permanent Link: Mobilize your website'>Mobilize your website</a> <small>Did you know that there are approximately 1.5 billion mobile...</small></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://www.zparacha.com/display-rss-feed-website/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Validate U.S Phone Numbers using JavaScript Regular expression.</title>
		<link>http://www.zparacha.com/phone_number_regex/</link>
		<comments>http://www.zparacha.com/phone_number_regex/#comments</comments>
		<pubDate>Fri, 29 Feb 2008 04:44:25 +0000</pubDate>
		<dc:creator>Zaheer</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[RegEx]]></category>
		<category><![CDATA[Regular Expression]]></category>

		<guid isPermaLink="false">http://www.zparacha.com/phone_number_regex/</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/phone_number_regex/' addthis:title='Validate U.S Phone Numbers using JavaScript Regular expression.' ><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a></div>Photo credit: aussiegall Continuing with our JavaScript regular expression series today we will discuss JavaScript regular expression to validate U.S phone number. Previously we talked about validating email , Social Security number and zip code using JS regex. In today&#8217;s post I&#8217;ll show you how to use JavaScript regular expression to validate U.S phone number. [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/phone_number_regex/' addthis:title='Validate U.S Phone Numbers using JavaScript Regular expression.' ><a class="addthis_button_googlereader"></a><a class="addthis_button_email"></a><a class="addthis_button_google"></a><a class="addthis_button_twitter"></a><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a><a class="addthis_button_compact"></a></div><p><a href="http://www.zparacha.com/phone_number_regex/">Validate U.S Phone Numbers using JavaScript Regular expression.</a> is a post from: <a href="http://www.zparacha.com">zParacha.com | Effective programming and blogging tips by Zaheer Paracha</a></p>



<span style="font-weight:bold;"> Related posts:</span><ul><li><a href='http://www.zparacha.com/validate-zip-code-using-javascript-regular-expression/' rel='bookmark' title='Permanent Link: Validate Zip code using JavaScript Regular expression'>Validate Zip code using JavaScript Regular expression</a> <small>Continuing with my series of JavaScript regular expression today we...</small></li>
<li><a href='http://www.zparacha.com/validate-email-address-using-javascript-regular-expression/' rel='bookmark' title='Permanent Link: Validate email address using JavaScript regular expression'>Validate email address using JavaScript regular expression</a> <small>Last month I wrote about regular expressions in Java, today...</small></li>
<li><a href='http://www.zparacha.com/validate-social-security-number-using-javascript-regular-expressions/' rel='bookmark' title='Permanent Link: How to validate Social Security Number (SSN) using JavaScript Regular Expressions'>How to validate Social Security Number (SSN) using JavaScript Regular Expressions</a> <small>When I wrote the JS regular expression article last week...</small></li>
</ul>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/phone_number_regex/' addthis:title='Validate U.S Phone Numbers using JavaScript Regular expression.' ><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a></div><div style="float: right"> <a href="http://www.flickr.com/photos/14516334@N00/279804967/" target="_blank"><img src="http://farm1.static.flickr.com/82/279804967_668397cde9_m.jpg" style="border: 0pt none;" title="Validate U.S Phone Numbers using JavaScript Regular expression." alt="279804967 668397cde9 m Validate U.S Phone Numbers using JavaScript Regular expression." /></a><br />
<small>Photo credit: <a href="http://www.flickr.com/photos/14516334@N00/279804967/" title="aussiegall" target="_blank">aussiegall</a></small>
</div>
<p>Continuing with our JavaScript regular expression series today we will discuss <!--google_ad_section_start-->JavaScript regular expression to validate U.S phone number.  Previously we talked about validating <a href="http://www.zparacha.com/validate-email-address-using-javascript-regular-expression/">email</a> , <a href="http://www.zparacha.com/more-javascript-regular-expressions/">Social Security number</a> and <a href="http://www.zparacha.com/validate-zip-code-using-javascript-regular-expression/">zip code </a> using JS regex.</p>
<p>In today&#8217;s post I&#8217;ll show you how to use JavaScript regular expression to validate U.S phone number.</p>
<p><!--google_ad_section_end--><br />
Although in this article we are discussing U.S phone number format I am sure this can be applied to other phone number formats with little or no change. </p>
<p>Let&#8217;s begin by looking at the JavaScript code.<br />
<!--google_ad_section_start--></p>
<pre name="code" class="JavaScript">

function validatePhoneNumber(elementValue){
var phoneNumberPattern = /^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$/;
return phoneNumberPattern.test(elementValue);
}</pre>
<p><!--adsense#336By280--></p>
<p><!--google_ad_section_end--></p>
<h4>Explanation:</h4>
<p>The argument to this method is the phone number you want to validate.</p>
<p>In the method body we define a variable (&#8216;phoneNumberPattern&#8217;) and assign a regular expression to it.</p>
<p><strong>Phone Number format</strong>: <!--google_ad_section_start-->The regular expression for phone number is <span id="more-82"></span></p>
<p><strong>/^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$/</strong></p>
<p><!--google_ad_section_end--></p>
<p><!--sadsense#tla--></p>
<p>Let&#8217;s divide this regular expression in smaller fragments to make is easy to understand.</p>
<p><span style="margin-right: 5px; font-weight: bold; font-size: 105%; color: #800080; border-bottom: #00ff00 2px solid; text-decoration: none"><br />
/^\(?</span>:  Means that the phone number may begin with an optional &#8220;(&#8220;.</p>
<p><span style="margin-right: 5px; font-weight: bold; font-size: 105%; color: #800080; border-bottom: #00ff00 2px solid; text-decoration: none"><br />
(\d{3})</span>: After the optional &#8220;(&#8221; there must be 3 numeric digits. If the phone number does not have a &#8220;(&#8220;, it must start with 3 digits. E.g. (308 or 308.</p>
<p><span style="margin-right: 5px; font-weight: bold; font-size: 105%; color: #800080; border-bottom: #00ff00 2px solid; text-decoration: none">\)?</span>:  Means that the phone number can have an optional &#8220;)&#8221; after first 3 digits.</p>
<p><span style="margin-right: 5px; font-weight: bold; font-size: 105%; color: #800080; border-bottom: #00ff00 2px solid; text-decoration: none">[- ]?</span>: Next the phone number can have an optional hyphen (&#8220;-&#8221;) after &#8220;)&#8221; if present or after first 3 digits.</p>
<p><span style="margin-right: 5px; font-weight: bold; font-size: 105%; color: #800080; border-bottom: #00ff00 2px solid; text-decoration: none">(\d{3})</span>: Then there must be 3 more numeric digits. E.g (308)-135 or 308-135 or 308135</p>
<p><span style="margin-right: 5px; font-weight: bold; font-size: 105%; color: #800080; border-bottom: #00ff00 2px solid; text-decoration: none">[- ]?</span>: After the second set of 3 digits the phone number can have another optional hyphen (&#8220;-&#8221;). E.g (308)-135- or 308-135- or 308135-
</p>
<p><span style="margin-right: 5px; font-weight: bold; font-size: 105%; color: #800080; border-bottom: #00ff00 2px solid; text-decoration: none">(\d{4})$/</span>: Finally, the phone number must end with four digits. E.g (308)-135-7895 or 308-135-7895 or 308135-7895 or 3081357895.
</p>
<p><!--google_ad_section_start--><br />
On the final line we call test method for our regular expression and pass the phone number as input. If the input phone number satisfies our regular expression, Ã¢â‚¬ËœtestÃ¢â‚¬â„¢ will return true otherwise it will return false. We return this value to the calling method.<br />
<!--google_ad_section_end--><br />
<!--adsense#tla-->
<div class="tweetmeme_button" style="float:right; margin: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.zparacha.com%2Fphone_number_regex%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.zparacha.com%2Fphone_number_regex%2F&amp;source=zparacha&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" title="Validate U.S Phone Numbers using JavaScript Regular expression." alt=" Validate U.S Phone Numbers using JavaScript Regular expression." /><br />
			</a>
		</div>
<p><a href="http://www.zparacha.com/phone_number_regex/">Validate U.S Phone Numbers using JavaScript Regular expression.</a> is a post from: <a href="http://www.zparacha.com">zParacha.com | Effective programming and blogging tips by Zaheer Paracha</a></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Validate U.S Phone Numbers using JavaScript Regular expression. on zParacha.com: Effective Programming tips',url: 'http://www.zparacha.com/phone_number_regex/',contentID: 'post-82',signature: 'If you enjoyed this post, make sure you subscribe to my &lt;a href=\&quot;http://www.zparacha.com/feed/\&quot;&gt; RSS feed&lt;/a&gt;.',suggestTags: 'Javascript,RegEx,Regular Expression',providerName: 'zParacha.com: Effective Programming tips',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-vert.png" class="evernoteSiteMemoryButton" title="Validate U.S Phone Numbers using JavaScript Regular expression." alt="article clipper vert Validate U.S Phone Numbers using JavaScript Regular expression." />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/phone_number_regex/' addthis:title='Validate U.S Phone Numbers using JavaScript Regular expression.' ><a class="addthis_button_googlereader"></a><a class="addthis_button_email"></a><a class="addthis_button_google"></a><a class="addthis_button_twitter"></a><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a><a class="addthis_button_compact"></a></div>

<p><span style="font-weight:bold;"> Related posts:</span><ul><li><a href='http://www.zparacha.com/validate-zip-code-using-javascript-regular-expression/' rel='bookmark' title='Permanent Link: Validate Zip code using JavaScript Regular expression'>Validate Zip code using JavaScript Regular expression</a> <small>Continuing with my series of JavaScript regular expression today we...</small></li>
<li><a href='http://www.zparacha.com/validate-email-address-using-javascript-regular-expression/' rel='bookmark' title='Permanent Link: Validate email address using JavaScript regular expression'>Validate email address using JavaScript regular expression</a> <small>Last month I wrote about regular expressions in Java, today...</small></li>
<li><a href='http://www.zparacha.com/validate-social-security-number-using-javascript-regular-expressions/' rel='bookmark' title='Permanent Link: How to validate Social Security Number (SSN) using JavaScript Regular Expressions'>How to validate Social Security Number (SSN) using JavaScript Regular Expressions</a> <small>When I wrote the JS regular expression article last week...</small></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://www.zparacha.com/phone_number_regex/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Validate Zip code using JavaScript Regular expression</title>
		<link>http://www.zparacha.com/validate-zip-code-using-javascript-regular-expression/</link>
		<comments>http://www.zparacha.com/validate-zip-code-using-javascript-regular-expression/#comments</comments>
		<pubDate>Mon, 18 Feb 2008 17:37:24 +0000</pubDate>
		<dc:creator>Zaheer</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Most Popular Posts]]></category>
		<category><![CDATA[RegEx]]></category>
		<category><![CDATA[Regular Expression]]></category>

		<guid isPermaLink="false">http://www.zparacha.com/validate-zip-code-using-javascript-regular-expression/</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/validate-zip-code-using-javascript-regular-expression/' addthis:title='Validate Zip code using JavaScript Regular expression' ><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a></div>Continuing with my series of JavaScript regular expression today we will see how easy it is to validate zip code using regular expression in JavaScript. Previously we talked about validating email and Social Security number using JS regex. In today&#8217;s post I&#8217;ll show you how to use JavaScript regular expression to validate zip code. Let [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/validate-zip-code-using-javascript-regular-expression/' addthis:title='Validate Zip code using JavaScript Regular expression' ><a class="addthis_button_googlereader"></a><a class="addthis_button_email"></a><a class="addthis_button_google"></a><a class="addthis_button_twitter"></a><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a><a class="addthis_button_compact"></a></div><p><a href="http://www.zparacha.com/validate-zip-code-using-javascript-regular-expression/">Validate Zip code using JavaScript Regular expression</a> is a post from: <a href="http://www.zparacha.com">zParacha.com | Effective programming and blogging tips by Zaheer Paracha</a></p>



<span style="font-weight:bold;"> Related posts:</span><ul><li><a href='http://www.zparacha.com/phone_number_regex/' rel='bookmark' title='Permanent Link: Validate U.S Phone Numbers using JavaScript Regular expression.'>Validate U.S Phone Numbers using JavaScript Regular expression.</a> <small>Photo credit: aussiegall Continuing with our JavaScript regular expression series...</small></li>
<li><a href='http://www.zparacha.com/validate-email-address-using-javascript-regular-expression/' rel='bookmark' title='Permanent Link: Validate email address using JavaScript regular expression'>Validate email address using JavaScript regular expression</a> <small>Last month I wrote about regular expressions in Java, today...</small></li>
<li><a href='http://www.zparacha.com/validate-social-security-number-using-javascript-regular-expressions/' rel='bookmark' title='Permanent Link: How to validate Social Security Number (SSN) using JavaScript Regular Expressions'>How to validate Social Security Number (SSN) using JavaScript Regular Expressions</a> <small>When I wrote the JS regular expression article last week...</small></li>
</ul>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/validate-zip-code-using-javascript-regular-expression/' addthis:title='Validate Zip code using JavaScript Regular expression' ><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a></div><p><div id="attachment_1172" class="wp-caption alignleft" style="width: 310px"><a href="http://www.zparacha.com/validate-zip-code-using-javascript-regular-expression/zipcode/" rel="attachment wp-att-1172"><img src="http://www.zparacha.com/wp-content/uploads/2008/02/zipcode-300x199.jpg" alt="zipcode 300x199 Validate Zip code using JavaScript Regular expression" title="zipcode" width="300" height="199" class="size-medium wp-image-1172" /></a><p class="wp-caption-text">Zip Code</p></div>Continuing with my series of JavaScript regular expression today we will see how easy it is to validate zip code using regular expression in JavaScript.  Previously we talked about validating <a href="http://www.zparacha.com/validate-email-address-using-javascript-regular-expression/">email</a> and <a href="http://www.zparacha.com/more-javascript-regular-expressions/">Social Security number</a> using JS regex.</p>
<p>In today&#8217;s post I&#8217;ll show you how to use JavaScript regular expression to validate zip code. Let me first show you the JS code.</p>
<pre><code>
function validateZipCode(elementValue){
    var zipCodePattern = /^\d{5}$|^\d{5}-\d{4}$/;
     return zipCodePattern.test(elementValue);
}
</code></pre>
<p><!--adsense#green1--></p>
<h4>Explanation:</h4>
<p>The argument to this method is the zip code you want to validate.</p>
<p>In the method body we define a variable (&#8216;zipCodePattern&#8217;) and assign a regular expression to it.</p>
<p><strong>ZipCode format</strong>: The regular expression for zip code is</p>
<p><span id="more-76"></span></p>
<p><strong>/^\d{5}$|^\d{5}-\d{4}$/</strong></p>
<p>This is quite a simple regular expression.</p>
<p><!--adsense#text_ad--></p>
<p>What we are saying here is that a valid zip code can either have 5 digits or 5 digits followed by an hyphen(-) and ends with four digits. So, zip codes 38980 and 83900-8789 will pass validation. However, 83900- or 839008789 will not pass our validation test.<br />
If you don&#8217;t want to have a zip+4 format you can use <strong>/^\d{5}$/</strong> as the regular expression to validate simple zip code.</p>
<p><span style="font-size:10px;color:#333;">Image credit:<a href="http://www.flickr.com/photos/smcgee/">smcgee</a></span>
<div class="tweetmeme_button" style="float:right; margin: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.zparacha.com%2Fvalidate-zip-code-using-javascript-regular-expression%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.zparacha.com%2Fvalidate-zip-code-using-javascript-regular-expression%2F&amp;source=zparacha&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" title="Validate Zip code using JavaScript Regular expression" alt=" Validate Zip code using JavaScript Regular expression" /><br />
			</a>
		</div>
<p><a href="http://www.zparacha.com/validate-zip-code-using-javascript-regular-expression/">Validate Zip code using JavaScript Regular expression</a> is a post from: <a href="http://www.zparacha.com">zParacha.com | Effective programming and blogging tips by Zaheer Paracha</a></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Validate Zip code using JavaScript Regular expression on zParacha.com: Effective Programming tips',url: 'http://www.zparacha.com/validate-zip-code-using-javascript-regular-expression/',contentID: 'post-76',signature: 'If you enjoyed this post, make sure you subscribe to my &lt;a href=\&quot;http://www.zparacha.com/feed/\&quot;&gt; RSS feed&lt;/a&gt;.',suggestTags: 'Javascript,RegEx,Regular Expression',providerName: 'zParacha.com: Effective Programming tips',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-vert.png" class="evernoteSiteMemoryButton" title="Validate Zip code using JavaScript Regular expression" alt="article clipper vert Validate Zip code using JavaScript Regular expression" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/validate-zip-code-using-javascript-regular-expression/' addthis:title='Validate Zip code using JavaScript Regular expression' ><a class="addthis_button_googlereader"></a><a class="addthis_button_email"></a><a class="addthis_button_google"></a><a class="addthis_button_twitter"></a><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a><a class="addthis_button_compact"></a></div>

<p><span style="font-weight:bold;"> Related posts:</span><ul><li><a href='http://www.zparacha.com/phone_number_regex/' rel='bookmark' title='Permanent Link: Validate U.S Phone Numbers using JavaScript Regular expression.'>Validate U.S Phone Numbers using JavaScript Regular expression.</a> <small>Photo credit: aussiegall Continuing with our JavaScript regular expression series...</small></li>
<li><a href='http://www.zparacha.com/validate-email-address-using-javascript-regular-expression/' rel='bookmark' title='Permanent Link: Validate email address using JavaScript regular expression'>Validate email address using JavaScript regular expression</a> <small>Last month I wrote about regular expressions in Java, today...</small></li>
<li><a href='http://www.zparacha.com/validate-social-security-number-using-javascript-regular-expressions/' rel='bookmark' title='Permanent Link: How to validate Social Security Number (SSN) using JavaScript Regular Expressions'>How to validate Social Security Number (SSN) using JavaScript Regular Expressions</a> <small>When I wrote the JS regular expression article last week...</small></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://www.zparacha.com/validate-zip-code-using-javascript-regular-expression/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>How to validate Social Security Number (SSN) using JavaScript Regular Expressions</title>
		<link>http://www.zparacha.com/validate-social-security-number-using-javascript-regular-expressions/</link>
		<comments>http://www.zparacha.com/validate-social-security-number-using-javascript-regular-expressions/#comments</comments>
		<pubDate>Sat, 16 Feb 2008 03:44:37 +0000</pubDate>
		<dc:creator>Zaheer</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.zparacha.com/more-javascript-regular-expressions/</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/validate-social-security-number-using-javascript-regular-expressions/' addthis:title='How to validate Social Security Number (SSN) using JavaScript Regular Expressions' ><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a></div>When I wrote the JS regular expression article last week I had no idea that it will attract so many visitors. Not only did so many people read this post, many more visited my blog searching for other regular expressions. So I decided to write few more posts about JavaScript regular expressions and how to [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/validate-social-security-number-using-javascript-regular-expressions/' addthis:title='How to validate Social Security Number (SSN) using JavaScript Regular Expressions' ><a class="addthis_button_googlereader"></a><a class="addthis_button_email"></a><a class="addthis_button_google"></a><a class="addthis_button_twitter"></a><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a><a class="addthis_button_compact"></a></div><p><a href="http://www.zparacha.com/validate-social-security-number-using-javascript-regular-expressions/">How to validate Social Security Number (SSN) using JavaScript Regular Expressions</a> is a post from: <a href="http://www.zparacha.com">zParacha.com | Effective programming and blogging tips by Zaheer Paracha</a></p>



<span style="font-weight:bold;"> Related posts:</span><ul><li><a href='http://www.zparacha.com/phone_number_regex/' rel='bookmark' title='Permanent Link: Validate U.S Phone Numbers using JavaScript Regular expression.'>Validate U.S Phone Numbers using JavaScript Regular expression.</a> <small>Photo credit: aussiegall Continuing with our JavaScript regular expression series...</small></li>
<li><a href='http://www.zparacha.com/validate-zip-code-using-javascript-regular-expression/' rel='bookmark' title='Permanent Link: Validate Zip code using JavaScript Regular expression'>Validate Zip code using JavaScript Regular expression</a> <small>Continuing with my series of JavaScript regular expression today we...</small></li>
<li><a href='http://www.zparacha.com/validate-email-address-using-javascript-regular-expression/' rel='bookmark' title='Permanent Link: Validate email address using JavaScript regular expression'>Validate email address using JavaScript regular expression</a> <small>Last month I wrote about regular expressions in Java, today...</small></li>
</ul>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/validate-social-security-number-using-javascript-regular-expressions/' addthis:title='How to validate Social Security Number (SSN) using JavaScript Regular Expressions' ><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a></div><p><!--adsense#greyLeft-->
<p>When I wrote the JS regular expression <a href="http://www.zparacha.com/validate-email-address-using-javascript-regular-expression/">article</a> last week I had no idea that it will attract so many visitors. Not only did so many people read this post, many more visited my blog searching for other regular expressions. So I decided to write few more posts about JavaScript regular expressions and how to use them to validate Social Security number, zip code, phone number and numeric data. I&#8217;ll divide these into smaller posts discussing one regular expression per post to keep it simple for the readers.</p>
<p>In today&#8217;s post I&#8217;ll show you how to use JavaScript regular expression to validate Social Security number. Let me first show you the JS code. </p>
<pre name="code" class="javascript">
    function validateSSN (elementValue){
       var  ssnPattern = /^[0-9]{3}\-?[0-9]{2}\-?[0-9]{4}$/;
       return ssnPattern.test(elementValue);
   }
</pre>
<p><!--adsense#green1--></p>
<h4>Explanation:</h4>
<p>The argument to this method is the social security number you want to validate.<br />
  <br />In the method body we define a variable (&#8216;ssnPattern&#8217;) and assign a regular expression to it.</p>
<p><strong>SNN format</strong>: The regular expression for social security number (SSN) is
</p>
<p><span id="more-75"></span></p>
<p><strong>/^[0-9]{3}\-?[0-9]{2}\-?[0-9]{4}$/</strong> </p>
<p>To understand the regular expression we will divide it into smaller components:</p>
<p><span style="padding-right: 5px; font-weight: bold; font-size: 105%; color: #800080; border-bottom: #00ff00 2px solid; text-decoration: none">/^[0-9]{3}</span>:&#160; Means that the social security number must begin with at least three numeric characters.</p>
<p><span style="padding-right: 5px; font-weight: bold; font-size: 105%; color: #800080; border-bottom: #00ff00 2px solid; text-decoration: none">\-?</span>:&#160;&#160; Means that SSN can have an optional hyphen (-) after first 3 digits. </p>
<p><span style="padding-right: 10px; font-weight: bold; font-size: 105%; color: #800080; border-bottom: #00ff00 1px solid; text-decoration: none">[0-9]{2}</span>: First 3 digits (or optional hyphen) must be followed by 2 more digits. </p>
<p><span style="padding-right: 5px; font-weight: bold; font-size: 105%; color: #800080; border-bottom: #00ff00 2px solid; text-decoration: none">\-?</span>: After the second group of digits there may be another optional hyphen (-) character.</p>
<p><span style="padding-right: 5px; font-weight: bold; font-size: 105%; color: #800080; border-bottom: #00ff00 2px solid; text-decoration: none">[0-9]{4}$/</span>: Finally, the social security number must end with four digits.</p>
<p>&#160;</p>
<p>On the final line we call <i>test</i> method for our regular expression and pass the social security number as input. If the input SSN satisfies our regular expression, &#8216;test&#8217; will return <i>true</i> otherwise it will return <i>false</i>. We return this value to the calling method.</p>
<p><!--adsense#text_ad--></p>
<p>You can call this method whenever you want to validate social security number.</p>
<p><strong>Examples:</strong></p>
<p>Following SSNs will pass validation : 345-90-98023, 234908908; 239-586767; 73467-8790</p>
<p>The method will return false for following SSNs. 34-909-9098; 34a-20-7678; </p>
<div class="tweetmeme_button" style="float:right; margin: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.zparacha.com%2Fvalidate-social-security-number-using-javascript-regular-expressions%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.zparacha.com%2Fvalidate-social-security-number-using-javascript-regular-expressions%2F&amp;source=zparacha&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" title="How to validate Social Security Number (SSN) using JavaScript Regular Expressions" alt=" How to validate Social Security Number (SSN) using JavaScript Regular Expressions" /><br />
			</a>
		</div>
<p><a href="http://www.zparacha.com/validate-social-security-number-using-javascript-regular-expressions/">How to validate Social Security Number (SSN) using JavaScript Regular Expressions</a> is a post from: <a href="http://www.zparacha.com">zParacha.com | Effective programming and blogging tips by Zaheer Paracha</a></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'How to validate Social Security Number (SSN) using JavaScript Regular Expressions on zParacha.com: Effective Programming tips',url: 'http://www.zparacha.com/validate-social-security-number-using-javascript-regular-expressions/',contentID: 'post-75',signature: 'If you enjoyed this post, make sure you subscribe to my &lt;a href=\&quot;http://www.zparacha.com/feed/\&quot;&gt; RSS feed&lt;/a&gt;.',suggestTags: '',providerName: 'zParacha.com: Effective Programming tips',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-vert.png" class="evernoteSiteMemoryButton" title="How to validate Social Security Number (SSN) using JavaScript Regular Expressions" alt="article clipper vert How to validate Social Security Number (SSN) using JavaScript Regular Expressions" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/validate-social-security-number-using-javascript-regular-expressions/' addthis:title='How to validate Social Security Number (SSN) using JavaScript Regular Expressions' ><a class="addthis_button_googlereader"></a><a class="addthis_button_email"></a><a class="addthis_button_google"></a><a class="addthis_button_twitter"></a><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a><a class="addthis_button_compact"></a></div>

<p><span style="font-weight:bold;"> Related posts:</span><ul><li><a href='http://www.zparacha.com/phone_number_regex/' rel='bookmark' title='Permanent Link: Validate U.S Phone Numbers using JavaScript Regular expression.'>Validate U.S Phone Numbers using JavaScript Regular expression.</a> <small>Photo credit: aussiegall Continuing with our JavaScript regular expression series...</small></li>
<li><a href='http://www.zparacha.com/validate-zip-code-using-javascript-regular-expression/' rel='bookmark' title='Permanent Link: Validate Zip code using JavaScript Regular expression'>Validate Zip code using JavaScript Regular expression</a> <small>Continuing with my series of JavaScript regular expression today we...</small></li>
<li><a href='http://www.zparacha.com/validate-email-address-using-javascript-regular-expression/' rel='bookmark' title='Permanent Link: Validate email address using JavaScript regular expression'>Validate email address using JavaScript regular expression</a> <small>Last month I wrote about regular expressions in Java, today...</small></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://www.zparacha.com/validate-social-security-number-using-javascript-regular-expressions/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Validate email address using JavaScript regular expression</title>
		<link>http://www.zparacha.com/validate-email-address-using-javascript-regular-expression/</link>
		<comments>http://www.zparacha.com/validate-email-address-using-javascript-regular-expression/#comments</comments>
		<pubDate>Fri, 08 Feb 2008 03:52:06 +0000</pubDate>
		<dc:creator>Zaheer</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.zparacha.com/validate-email-address-using-javascript-regular-expression/</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/validate-email-address-using-javascript-regular-expression/' addthis:title='Validate email address using JavaScript regular expression' ><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a></div>Last month I wrote about regular expressions in Java, today I&#8217;ll show you how to use regular expression in JavaScript to validate email address. Here is the code to validate email address in JavaScript using regular expression. function validateEmail(elementValue){ var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; return emailPattern.test(elementValue); } Explanation: The argument to this method is the email [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/validate-email-address-using-javascript-regular-expression/' addthis:title='Validate email address using JavaScript regular expression' ><a class="addthis_button_googlereader"></a><a class="addthis_button_email"></a><a class="addthis_button_google"></a><a class="addthis_button_twitter"></a><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a><a class="addthis_button_compact"></a></div><p><a href="http://www.zparacha.com/validate-email-address-using-javascript-regular-expression/">Validate email address using JavaScript regular expression</a> is a post from: <a href="http://www.zparacha.com">zParacha.com | Effective programming and blogging tips by Zaheer Paracha</a></p>



<span style="font-weight:bold;"> Related posts:</span><ul><li><a href='http://www.zparacha.com/ultimate-java-regular-expression-to-validate-email-address/' rel='bookmark' title='Permanent Link: Ultimate Java Regular Expression to validate any email address.'>Ultimate Java Regular Expression to validate any email address.</a> <small>My post about Java regular expression gets a lot of...</small></li>
<li><a href='http://www.zparacha.com/validate-zip-code-using-javascript-regular-expression/' rel='bookmark' title='Permanent Link: Validate Zip code using JavaScript Regular expression'>Validate Zip code using JavaScript Regular expression</a> <small>Continuing with my series of JavaScript regular expression today we...</small></li>
<li><a href='http://www.zparacha.com/phone_number_regex/' rel='bookmark' title='Permanent Link: Validate U.S Phone Numbers using JavaScript Regular expression.'>Validate U.S Phone Numbers using JavaScript Regular expression.</a> <small>Photo credit: aussiegall Continuing with our JavaScript regular expression series...</small></li>
</ul>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/validate-email-address-using-javascript-regular-expression/' addthis:title='Validate email address using JavaScript regular expression' ><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a></div><p><!--adsense#336By280--></p>
<p>Last month I wrote about <a title="Java reg ex" href="http://www.zparacha.com/java_regex_validation/" target="_blank">regular expressions in Java</a>, today I&#8217;ll show you how to use regular expression in JavaScript to validate email address.</p>
<p>Here is the code to validate email address in JavaScript using regular expression.</p>
<p>
<pre name="code" class="javascript">
function validateEmail(elementValue){
   var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
   return emailPattern.test(elementValue);
 }
</pre>
</p>
<p/>
<h4>Explanation:</h4>
<p>The argument to this method is the email address you want to validate.    <br />In the method body we define a variable (&#8216;emailPattern&#8217;) and assign a regular expression to it.</p>
<p/><strong>Email format</strong>: The regular expression for email is<br />
<span id="more-66"></span><br />
 <strong>/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/</strong>
<p/>
<p><!--adsense-tla--> </p>
<p>To understand the regular expression we will divide it into smaller components:</p>
<p><span style="padding-right: 5px; font-weight: bold; font-size: 105%; color: #800080; border-bottom: #00ff00 2px solid; text-decoration: none">/^[a-zA-Z0-9._-]+</span>:&#160; Means that the email address must begin with alpha-numeric characters (both lowercase and uppercase characters are allowed). It may have periods,underscores and hyphens.</p>
<p>
<!--adsense_green1_bk--><br />
<span style="padding-right: 5px; font-weight: bold; font-size: 105%; color: #800080; border-bottom: #00ff00 2px solid; text-decoration: none">@</span>:&#160;&#160; There must be a &#8216;@&#8217; symbol after initial characters.</p>
<p><span style="padding-right: 10px; font-weight: bold; font-size: 105%; color: #800080; border-bottom: #00ff00 1px solid; text-decoration: none">[a-zA-Z0-9.-]+</span>: After the &#8216;@&#8217; sign there must be some alpha-numeric characters. It can also contain period (&#8216;.&#8217;) and and hyphens(&#8216;-&#8217;).</p>
<p><span style="padding-right: 5px; font-weight: bold; font-size: 105%; color: #800080; border-bottom: #00ff00 2px solid; text-decoration: none">\.</span>: After the second group of characters there must be a period (&#8216;.&#8217;). This is to separate domain and subdomain names.</p>
<p><span style="padding-right: 5px; font-weight: bold; font-size: 105%; color: #800080; border-bottom: #00ff00 2px solid; text-decoration: none">[a-zA-Z]{2,4}$/</span>: Finally, the email address must end with two to four alphabets. Having a-z and A-Z means that both lowercase and uppercase letters are allowed.     <br />{2,4} indicates the minimum and maximum number of characters. This will allow domain names with 2, 3 and 4 characters e.g.; us, tx, org, com, net, wxyz).</p>
<p>
<!--adsense_top--><br />
On the final line we call <i>test</i> method for our regular expression and pass the email address as input. If the input email address satisfies our regular expression, &#8216;test&#8217; will return <i>true</i> otherwise it will return <i>false</i>. We return this value to the calling method.</p>
<p>You can call this method whenever you want to validate email address.</p>
<div class="tweetmeme_button" style="float:right; margin: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.zparacha.com%2Fvalidate-email-address-using-javascript-regular-expression%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.zparacha.com%2Fvalidate-email-address-using-javascript-regular-expression%2F&amp;source=zparacha&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" title="Validate email address using JavaScript regular expression" alt=" Validate email address using JavaScript regular expression" /><br />
			</a>
		</div>
<p><a href="http://www.zparacha.com/validate-email-address-using-javascript-regular-expression/">Validate email address using JavaScript regular expression</a> is a post from: <a href="http://www.zparacha.com">zParacha.com | Effective programming and blogging tips by Zaheer Paracha</a></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Validate email address using JavaScript regular expression on zParacha.com: Effective Programming tips',url: 'http://www.zparacha.com/validate-email-address-using-javascript-regular-expression/',contentID: 'post-66',signature: 'If you enjoyed this post, make sure you subscribe to my &lt;a href=\&quot;http://www.zparacha.com/feed/\&quot;&gt; RSS feed&lt;/a&gt;.',suggestTags: '',providerName: 'zParacha.com: Effective Programming tips',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-vert.png" class="evernoteSiteMemoryButton" title="Validate email address using JavaScript regular expression" alt="article clipper vert Validate email address using JavaScript regular expression" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/validate-email-address-using-javascript-regular-expression/' addthis:title='Validate email address using JavaScript regular expression' ><a class="addthis_button_googlereader"></a><a class="addthis_button_email"></a><a class="addthis_button_google"></a><a class="addthis_button_twitter"></a><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a><a class="addthis_button_compact"></a></div>

<p><span style="font-weight:bold;"> Related posts:</span><ul><li><a href='http://www.zparacha.com/ultimate-java-regular-expression-to-validate-email-address/' rel='bookmark' title='Permanent Link: Ultimate Java Regular Expression to validate any email address.'>Ultimate Java Regular Expression to validate any email address.</a> <small>My post about Java regular expression gets a lot of...</small></li>
<li><a href='http://www.zparacha.com/validate-zip-code-using-javascript-regular-expression/' rel='bookmark' title='Permanent Link: Validate Zip code using JavaScript Regular expression'>Validate Zip code using JavaScript Regular expression</a> <small>Continuing with my series of JavaScript regular expression today we...</small></li>
<li><a href='http://www.zparacha.com/phone_number_regex/' rel='bookmark' title='Permanent Link: Validate U.S Phone Numbers using JavaScript Regular expression.'>Validate U.S Phone Numbers using JavaScript Regular expression.</a> <small>Photo credit: aussiegall Continuing with our JavaScript regular expression series...</small></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://www.zparacha.com/validate-email-address-using-javascript-regular-expression/feed/</wfw:commentRss>
		<slash:comments>91</slash:comments>
		</item>
		<item>
		<title>Set focus on the first text field of HTML form.</title>
		<link>http://www.zparacha.com/textfield_focus/</link>
		<comments>http://www.zparacha.com/textfield_focus/#comments</comments>
		<pubDate>Thu, 31 Jan 2008 05:14:06 +0000</pubDate>
		<dc:creator>Zaheer</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.zparacha.com/textfield_focus/</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/textfield_focus/' addthis:title='Set focus on the first text field of HTML form.' ><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a></div>A HTML form is a very good channel that you can offer to your visitors to contact you. An aesthetically appealing form encourages user to fill and submit it. It is equally important to make the form as user friendly as possible. Today I&#8217;ll share a small JavaScript function that will set the focus on [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/textfield_focus/' addthis:title='Set focus on the first text field of HTML form.' ><a class="addthis_button_googlereader"></a><a class="addthis_button_email"></a><a class="addthis_button_google"></a><a class="addthis_button_twitter"></a><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a><a class="addthis_button_compact"></a></div><p><a href="http://www.zparacha.com/textfield_focus/">Set focus on the first text field of HTML form.</a> is a post from: <a href="http://www.zparacha.com">zParacha.com | Effective programming and blogging tips by Zaheer Paracha</a></p>



<span style="font-weight:bold;"> Related posts:</span><ul><li><a href='http://www.zparacha.com/css-text-resize/' rel='bookmark' title='Permanent Link: Dynamically Resize Text'>Dynamically Resize Text</a> <small>.codeText{color:blue;font-weight:normal;width:100%;} .subhead{color:gray;font-weight:bold;text-decoration:underline;} CSS, combined with little JavaScript, offers great flexibility...</small></li>
<li><a href='http://www.zparacha.com/ajax-contact-from/' rel='bookmark' title='Permanent Link: AJAX Contact Form'>AJAX Contact Form</a> <small>Want to collect input from your web site&#8217;s visitors? Don&#8217;t...</small></li>
<li><a href='http://www.zparacha.com/better-alternative-to-onload/' rel='bookmark' title='Permanent Link: Why you should stop using onload method.'>Why you should stop using onload method.</a> <small>It is amazing that many web developers still use onload...</small></li>
</ul>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/textfield_focus/' addthis:title='Set focus on the first text field of HTML form.' ><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a></div><p>A HTML form is a very good channel that you can offer to your visitors to contact you. An aesthetically appealing form encourages user to fill and submit it. It is equally important to make the form as user friendly as possible. Today I&#8217;ll share a small JavaScript function that will set the focus on the first editable text field of your form. So when the web page loads the users don&#8217;t have to click on the text field. They can just start typing as soon as the form loads.</p>
<p>Here is the JavaScript code.</p>
<blockquote>
<pre>
<strong>function setFocus()</strong>{
 var flag=false;
 for(z=0;z&lt;document.forms.length;z++){
  var form = document.forms[z];
  var elements = form.elements;
  for (var i=0;i&lt;elements.length;i++){
    var element = elements[i];
    if(element.type == 'text' &amp;&amp;
      !element.readOnly &amp;&amp;
      !element.disabled){
      element.focus();
	  flag=true;
     break;
    }
  }
  if(flag)break;
 }
}</pre>
</blockquote>
<p><!--adsense#green1--></p>
<h3>How to use this script.</h3>
<p>Save the script in a text file and name it focus.js.</p>
<p>To use script copy and paste following line into the header section of your form HTML file.</p>
<blockquote><p>&lt;script type=&#8221;text/javascript&#8221; src=&#8221;focus.js&#8221;&gt;</p></blockquote>
<p>If you saved the focus.js to a separate directory, include the directory with the file name (like src=&#8221;js/focus.js&#8221;).</p>
<p>Now add</p>
<blockquote><p>onLoad=&#8221;setFocus();&#8221;</p></blockquote>
<p>to the body tag.<br />
Your body tag will become</p>
<blockquote><p>&lt;body onLoad=&#8221;setFocus(&#8216;contactForm&#8217;);&#8221; &gt;</p></blockquote>
<p>Now when your page loads the focus will be on the first editable textfield on your form.Click <a href="http://www.zparacha.com/examples/form/fieldFocus.html">here</a> to see an example.</p>
<p><!--adsense#tla-->
<div class="tweetmeme_button" style="float:right; margin: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.zparacha.com%2Ftextfield_focus%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.zparacha.com%2Ftextfield_focus%2F&amp;source=zparacha&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" title="Set focus on the first text field of HTML form." alt=" Set focus on the first text field of HTML form." /><br />
			</a>
		</div>
<p><a href="http://www.zparacha.com/textfield_focus/">Set focus on the first text field of HTML form.</a> is a post from: <a href="http://www.zparacha.com">zParacha.com | Effective programming and blogging tips by Zaheer Paracha</a></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Set focus on the first text field of HTML form. on zParacha.com: Effective Programming tips',url: 'http://www.zparacha.com/textfield_focus/',contentID: 'post-63',signature: 'If you enjoyed this post, make sure you subscribe to my &lt;a href=\&quot;http://www.zparacha.com/feed/\&quot;&gt; RSS feed&lt;/a&gt;.',suggestTags: '',providerName: 'zParacha.com: Effective Programming tips',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-vert.png" class="evernoteSiteMemoryButton" title="Set focus on the first text field of HTML form." alt="article clipper vert Set focus on the first text field of HTML form." />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/textfield_focus/' addthis:title='Set focus on the first text field of HTML form.' ><a class="addthis_button_googlereader"></a><a class="addthis_button_email"></a><a class="addthis_button_google"></a><a class="addthis_button_twitter"></a><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a><a class="addthis_button_compact"></a></div>

<p><span style="font-weight:bold;"> Related posts:</span><ul><li><a href='http://www.zparacha.com/css-text-resize/' rel='bookmark' title='Permanent Link: Dynamically Resize Text'>Dynamically Resize Text</a> <small>.codeText{color:blue;font-weight:normal;width:100%;} .subhead{color:gray;font-weight:bold;text-decoration:underline;} CSS, combined with little JavaScript, offers great flexibility...</small></li>
<li><a href='http://www.zparacha.com/ajax-contact-from/' rel='bookmark' title='Permanent Link: AJAX Contact Form'>AJAX Contact Form</a> <small>Want to collect input from your web site&#8217;s visitors? Don&#8217;t...</small></li>
<li><a href='http://www.zparacha.com/better-alternative-to-onload/' rel='bookmark' title='Permanent Link: Why you should stop using onload method.'>Why you should stop using onload method.</a> <small>It is amazing that many web developers still use onload...</small></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://www.zparacha.com/textfield_focus/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Sort numbers in Javascript array</title>
		<link>http://www.zparacha.com/sort_numeric_arrays/</link>
		<comments>http://www.zparacha.com/sort_numeric_arrays/#comments</comments>
		<pubDate>Thu, 06 Dec 2007 04:19:11 +0000</pubDate>
		<dc:creator>Zaheer</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Array]]></category>
		<category><![CDATA[numeric array]]></category>
		<category><![CDATA[Sort]]></category>
		<category><![CDATA[Sort numbers]]></category>
		<category><![CDATA[sort numeric arrays]]></category>

		<guid isPermaLink="false">http://www.zparacha.com/sort_numeric_arrays/</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/sort_numeric_arrays/' addthis:title='Sort numbers in Javascript array' ><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a></div>Sorting an array in Javascript is a snap. You create an array and then call sort() method on that array. The Javascript sort() method sorts an array in lexicographical order. This method is very useful in sorting alphanumeric values of an array. However, sort() will not work if the array consists of numeric values. Because [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/sort_numeric_arrays/' addthis:title='Sort numbers in Javascript array' ><a class="addthis_button_googlereader"></a><a class="addthis_button_email"></a><a class="addthis_button_google"></a><a class="addthis_button_twitter"></a><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a><a class="addthis_button_compact"></a></div><p><a href="http://www.zparacha.com/sort_numeric_arrays/">Sort numbers in Javascript array</a> is a post from: <a href="http://www.zparacha.com">zParacha.com | Effective programming and blogging tips by Zaheer Paracha</a></p>



<span style="font-weight:bold;"> Related posts:</span><ul><li><a href='http://www.zparacha.com/sort-numbers-in-java-find-minimum-and-maximum-values-without-using-array/' rel='bookmark' title='Permanent Link: Sort numbers in Java to find minimum and maximum values without using Array'>Sort numbers in Java to find minimum and maximum values without using Array</a> <small>Recently a reader contacted me with a question about sorting...</small></li>
<li><a href='http://www.zparacha.com/sort-vector-elements/' rel='bookmark' title='Permanent Link: Automatically Sort Vector Elements'>Automatically Sort Vector Elements</a> <small>Vector class in java.util package is very easy to use....</small></li>
<li><a href='http://www.zparacha.com/phone_number_regex/' rel='bookmark' title='Permanent Link: Validate U.S Phone Numbers using JavaScript Regular expression.'>Validate U.S Phone Numbers using JavaScript Regular expression.</a> <small>Photo credit: aussiegall Continuing with our JavaScript regular expression series...</small></li>
</ul>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/sort_numeric_arrays/' addthis:title='Sort numbers in Javascript array' ><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a></div><p><a href="http://www.flickr.com/photo_zoom.gne?id=1603771987&amp;size=s"><img src="http://www.zparacha.com/images/numbers.jpg" class="right" alt="numbers Sort numbers in Javascript array" align="right" title="Sort numbers in Javascript array" /></a><br />
Sorting an array in Javascript is a snap.<br />
You create an array and then call sort() method on that array. The Javascript sort() method sorts an array in lexicographical order. This method is very useful in sorting alphanumeric values of an array. <!--adsense#greyLeft-->However, sort() will not work if the array consists of numeric values.  Because the alphabetical order of numbers is different from their numeric order the sorted array may not be in the order you are expecting. For example, in a dictionary sort the number &#8220;11&#8243; would come before number &#8220;5&#8243;. This may not be the result that you are looking for.<br />
Here is an example<br />
<code><br />
var ages = new Array (23,6,2,16,48,9,6);<br />
ages.sort();<br />
</code><br />
The array will become <strong>(16,2,23,48,6,6,9)</strong></p>
<p>Fortunately, the work around for this problem is quite simple.<br />
<span id="more-42"></span> You use the same sort() method but with an additional argument. This optional argument is a reference to a comparison method that tells sort() how to compare the elements.</p>
<p>Here is very simple compare method. What you name your function is not important. You can call it whatever you like. The important things are the two arguments and the return statement.<br />
<code><br />
function compare(a,b){<br />
return a-b;<br />
}<br />
</code><br />
Example:<br />
<code>var ages = new Array (23,6,2,16,48,9,6);<br />
ages.sort(compare);<br />
</code><br />
Result: <strong>(2,6,6,9,16,23,48).</strong></p>
<p>So how does it all work? There is no magic trick here. When you provide your comparison method to sort() you control how the elements are compared. If your <strong>compare(a,b) </strong>method returns</p>
<ul>
<li>a positive value (a number greater than 0) &#8216;a&#8217; will be put before &#8216;b&#8217;.</li>
<li> a negative value (a number greater than 0) &#8216;b&#8217; will be put before &#8216;a&#8217;.</li>
<li> 0 (meaning &#8216;a&#8217; and &#8216;b&#8217; are equal) then the positions of these two elements will not change in the sorted array.</li>
</ul>
<p>This array is sorted in ascending order. If you want to sort in descending order use following method<br />
<code>function compare(a,b){<br />
return b-a;<br />
} </code></p>
<p>Hope this helps.</p>
<p><!--adsense-->
<div class="tweetmeme_button" style="float:right; margin: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.zparacha.com%2Fsort_numeric_arrays%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.zparacha.com%2Fsort_numeric_arrays%2F&amp;source=zparacha&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" title="Sort numbers in Javascript array" alt=" Sort numbers in Javascript array" /><br />
			</a>
		</div>
<p><a href="http://www.zparacha.com/sort_numeric_arrays/">Sort numbers in Javascript array</a> is a post from: <a href="http://www.zparacha.com">zParacha.com | Effective programming and blogging tips by Zaheer Paracha</a></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Sort numbers in Javascript array on zParacha.com: Effective Programming tips',url: 'http://www.zparacha.com/sort_numeric_arrays/',contentID: 'post-42',signature: 'If you enjoyed this post, make sure you subscribe to my &lt;a href=\&quot;http://www.zparacha.com/feed/\&quot;&gt; RSS feed&lt;/a&gt;.',suggestTags: 'Array,Javascript,numeric array,Sort,Sort numbers,sort numeric arrays',providerName: 'zParacha.com: Effective Programming tips',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-vert.png" class="evernoteSiteMemoryButton" title="Sort numbers in Javascript array" alt="article clipper vert Sort numbers in Javascript array" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/sort_numeric_arrays/' addthis:title='Sort numbers in Javascript array' ><a class="addthis_button_googlereader"></a><a class="addthis_button_email"></a><a class="addthis_button_google"></a><a class="addthis_button_twitter"></a><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a><a class="addthis_button_compact"></a></div>

<p><span style="font-weight:bold;"> Related posts:</span><ul><li><a href='http://www.zparacha.com/sort-numbers-in-java-find-minimum-and-maximum-values-without-using-array/' rel='bookmark' title='Permanent Link: Sort numbers in Java to find minimum and maximum values without using Array'>Sort numbers in Java to find minimum and maximum values without using Array</a> <small>Recently a reader contacted me with a question about sorting...</small></li>
<li><a href='http://www.zparacha.com/sort-vector-elements/' rel='bookmark' title='Permanent Link: Automatically Sort Vector Elements'>Automatically Sort Vector Elements</a> <small>Vector class in java.util package is very easy to use....</small></li>
<li><a href='http://www.zparacha.com/phone_number_regex/' rel='bookmark' title='Permanent Link: Validate U.S Phone Numbers using JavaScript Regular expression.'>Validate U.S Phone Numbers using JavaScript Regular expression.</a> <small>Photo credit: aussiegall Continuing with our JavaScript regular expression series...</small></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://www.zparacha.com/sort_numeric_arrays/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Compress JavaScript and CSS files to optimize website speed.</title>
		<link>http://www.zparacha.com/compress-js-css/</link>
		<comments>http://www.zparacha.com/compress-js-css/#comments</comments>
		<pubDate>Fri, 23 Nov 2007 01:46:55 +0000</pubDate>
		<dc:creator>Zaheer</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Compress CSS]]></category>
		<category><![CDATA[Compress JavaScript]]></category>
		<category><![CDATA[Compressing JavaScript CSS]]></category>
		<category><![CDATA[Optimization]]></category>
		<category><![CDATA[Optimizing]]></category>
		<category><![CDATA[website optimization]]></category>

		<guid isPermaLink="false">http://www.zparacha.com/compress-js-css/</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/compress-js-css/' addthis:title='Compress JavaScript and CSS files to optimize website speed.' ><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a></div>Referencing external JavaScript and/or CSS files from a web page considerably increases the load time. As a rule of thumb remember that each external file requires additional HTTP request by the browser, hence the time to render a page will increase. Every web developer worth their salt should make optimization their priority. Fortunately, since this [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/compress-js-css/' addthis:title='Compress JavaScript and CSS files to optimize website speed.' ><a class="addthis_button_googlereader"></a><a class="addthis_button_email"></a><a class="addthis_button_google"></a><a class="addthis_button_twitter"></a><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a><a class="addthis_button_compact"></a></div><p><a href="http://www.zparacha.com/compress-js-css/">Compress JavaScript and CSS files to optimize website speed.</a> is a post from: <a href="http://www.zparacha.com">zParacha.com | Effective programming and blogging tips by Zaheer Paracha</a></p>



<span style="font-weight:bold;"> Related posts:</span><ul><li><a href='http://www.zparacha.com/share_files_with_dropbox/' rel='bookmark' title='Permanent Link: Share your files with DropBox'>Share your files with DropBox</a> <small>Everyone likes to share files and photos online with friends...</small></li>
<li><a href='http://www.zparacha.com/include-externaljar-file-in-maven/' rel='bookmark' title='Permanent Link: How to add external jar files to Maven project POM'>How to add external jar files to Maven project POM</a> <small>Maven has made compiling Java projects almost an effortless job....</small></li>
<li><a href='http://www.zparacha.com/dynamically-loading-an-external-javascript-or-css-file/' rel='bookmark' title='Permanent Link: Dynamically loading an external JavaScript or CSS file'>Dynamically loading an external JavaScript or CSS file</a> <small>A very good article explaining how to load JavaScript and...</small></li>
</ul>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/compress-js-css/' addthis:title='Compress JavaScript and CSS files to optimize website speed.' ><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a></div><p>Referencing external JavaScript and/or CSS files from a web page considerably increases the load time.<!--adsense#green1-->	 As a rule of thumb remember that each external file requires additional HTTP request by the browser, hence the time to render a page will increase. Every web developer worth their salt should make optimization their priority. Fortunately, since this is such a common issue many people have thought about it and came up with solutions.<br />
Below is a list of few of these solutions to optimize your website by compressing JavaScript and CSS files.</p>
<p><span id="more-40"></span><br />
But before you start optimizing your website, I recommend that you visit <a href="http://www.websiteoptimization.com">WebSiteOptimization</a> to analyze your website. Save the results and after you are done with your optimization analyze your website again and compare the before and after results. I bet you will be pleasantly surprised.</p>
<ul>
<li> <a href="http://tinyurl.com/y8vuka">Make Your Pages Load Faster </a><br />
<blockquote><p>&#8220;The idea is that you have one directory for CSS files and one directory for javascript files on your server. If you rewrite the URLs that point to these directories to a small script that intercepts the requests for those files. The script loads the file from disk and compresses it using gzip. It then sends that compressed file back to the browser. Given that JavaScript and CSS files compress really well this will greatly decrease the size of the data that is going to be transferred and thus decrease the time needed to download these files. Because this works completely transparently you do not need to change anything in your existing code.&#8221;</p></blockquote>
</li>
<li> <a href="http://tinyurl.com/pzpyy">Serving JavaScript Fast</a><br />
<blockquote><p> &#8220;With our so-called &#8220;Web 2.0&#8243; applications and their rich content and interaction, we expect our applications to increasingly make use of CSS and JavaScript. To make sure these applications are nice and snappy to use, we need to optimize the size and nature of content required to render the page, making sure we&#8217;re delivering the optimum experience. In practice, this means a combination of making our content as small and fast to download as possible, while avoiding unnecessarily refetching unmodified resources.&#8221;</p></blockquote>
</li>
<li><a href="http://www.julienlecomte.net/yuicompressor/">YUI Compressor for JavaScript and CSS</a><br />
<blockquote><p> &#8220;The YUI Compressor is a JavaScript compressor which, in addition to removing comments and white-spaces, obfuscates local variables using the smallest possible variable name. This obfuscation is safe, even when using constructs such as &#8216;eval&#8217; or &#8216;with&#8217; (although the compression is not optimal is those cases) Compared to jsmin, the average savings is around 20%. The YUI Compressor is also able to safely compress CSS files. The decision on which compressor is being used is made on the file extension (js or css).&#8221;</p></blockquote>
</li>
<li> <a href="http://tinyurl.com/jeyy3">JSMin- The JavaScript Minifier </a><br />
<blockquote><p>&#8220;JSMin is a filter which removes comments and unnecessary whitespace from JavaScript files. It typically reduces filesize by half, resulting in faster downloads. It also encourages a more expressive programming style because it eliminates the download cost of clean, literate self-documentation.&#8221;</p></blockquote>
</li>
<li> <a href="http://dean.edwards.name/packer/">Packer &#8211; A JavaScript Compressor</a><br />
Online JavaScript Compressor. You can also download PHP, perl and .NET versions of this tool.</li>
<li> <a href="http://www.cleancss.com/">CSS Formatter and Optimiser</a><br />
<blockquote><p> CleanCSS is a powerful CSS optimizer and formatter. Basically, it takes your CSS code and makes it cleaner and more concise. It helps you get smaller CSS file sizes and better written code. The way the optimizer works actually lets you decide how much compression you want. From super compressed (virtually unreadable and editable by a human being) to visually pleasing. I prefer the standard setting because it gives you a little of both.</p></blockquote>
</li>
</ul>
<p>This is just a sampling of the tools available for optimizing JavaScript and CSS files. This is not an exhaustive list and I am sure you can find many more tools online. The point is to consider optimization when you design and develop your website. If you know any other optimization tool or technique send that to me and I&#8217;ll be glad to add that to this list.<br />
Happy optimization!</p>
<p><!--adsense-->
<div class="tweetmeme_button" style="float:right; margin: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.zparacha.com%2Fcompress-js-css%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.zparacha.com%2Fcompress-js-css%2F&amp;source=zparacha&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" title="Compress JavaScript and CSS files to optimize website speed." alt=" Compress JavaScript and CSS files to optimize website speed." /><br />
			</a>
		</div>
<p><a href="http://www.zparacha.com/compress-js-css/">Compress JavaScript and CSS files to optimize website speed.</a> is a post from: <a href="http://www.zparacha.com">zParacha.com | Effective programming and blogging tips by Zaheer Paracha</a></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Compress JavaScript and CSS files to optimize website speed. on zParacha.com: Effective Programming tips',url: 'http://www.zparacha.com/compress-js-css/',contentID: 'post-40',signature: 'If you enjoyed this post, make sure you subscribe to my &lt;a href=\&quot;http://www.zparacha.com/feed/\&quot;&gt; RSS feed&lt;/a&gt;.',suggestTags: 'Compress CSS,Compress JavaScript,Compressing JavaScript CSS,Optimization,Optimizing,website optimization',providerName: 'zParacha.com: Effective Programming tips',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-vert.png" class="evernoteSiteMemoryButton" title="Compress JavaScript and CSS files to optimize website speed." alt="article clipper vert Compress JavaScript and CSS files to optimize website speed." />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/compress-js-css/' addthis:title='Compress JavaScript and CSS files to optimize website speed.' ><a class="addthis_button_googlereader"></a><a class="addthis_button_email"></a><a class="addthis_button_google"></a><a class="addthis_button_twitter"></a><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a><a class="addthis_button_compact"></a></div>

<p><span style="font-weight:bold;"> Related posts:</span><ul><li><a href='http://www.zparacha.com/share_files_with_dropbox/' rel='bookmark' title='Permanent Link: Share your files with DropBox'>Share your files with DropBox</a> <small>Everyone likes to share files and photos online with friends...</small></li>
<li><a href='http://www.zparacha.com/include-externaljar-file-in-maven/' rel='bookmark' title='Permanent Link: How to add external jar files to Maven project POM'>How to add external jar files to Maven project POM</a> <small>Maven has made compiling Java projects almost an effortless job....</small></li>
<li><a href='http://www.zparacha.com/dynamically-loading-an-external-javascript-or-css-file/' rel='bookmark' title='Permanent Link: Dynamically loading an external JavaScript or CSS file'>Dynamically loading an external JavaScript or CSS file</a> <small>A very good article explaining how to load JavaScript and...</small></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://www.zparacha.com/compress-js-css/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

