<?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>techtamasha.com &#187; JavaScript</title>
	<atom:link href="http://www.techtamasha.com/category/javascript/feed" rel="self" type="application/rss+xml" />
	<link>http://www.techtamasha.com</link>
	<description>a new play everyday</description>
	<lastBuildDate>Fri, 13 Jan 2012 09:21:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>How to dynamically call javascript functions</title>
		<link>http://www.techtamasha.com/how-to-dynamically-call-javascript-functions/116</link>
		<comments>http://www.techtamasha.com/how-to-dynamically-call-javascript-functions/116#comments</comments>
		<pubDate>Sat, 22 May 2010 11:47:01 +0000</pubDate>
		<dc:creator>Nischal Shetty</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[call dynamic function]]></category>
		<category><![CDATA[javascript dynamic]]></category>
		<category><![CDATA[javascript dynamic function]]></category>

		<guid isPermaLink="false">http://www.techtamasha.com/?p=116</guid>
		<description><![CDATA[I&#8217;ve had a lot of moments when I needed to call a javascript function dynamically. By dynamic function call in javascript, I mean when you do not know the function name to be called before hand i.e. the function name to be executed is provided at runtime. All you need to do is &#8211; window["functionname"](); [...]]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:100px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.techtamasha.com%2Fhow-to-dynamically-call-javascript-functions%2F116&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:110px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="How to dynamically call javascript functions" data-url="http://www.techtamasha.com/how-to-dynamically-call-javascript-functions/116" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>I&#8217;ve had a lot of moments when I needed to call a javascript function dynamically. By dynamic function call in javascript, I mean when you do not know the function name to be called before hand i.e. the function name to be executed is provided at runtime.</p>
<p>All you need to do is &#8211; <strong>window["functionname"]();</strong></p>
<p>Yeah, that&#8217;s all! Here <strong>functionname</strong> would be replaced with the name of your function. As always, I&#8217;ll provide a working example so that there is no confusion as to how to make dynamic function calls in Javascript.</p>
<p><script src="http://gist.github.com/410013.js"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.techtamasha.com/how-to-dynamically-call-javascript-functions/116/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript Substring function</title>
		<link>http://www.techtamasha.com/javascript-substring-function/76</link>
		<comments>http://www.techtamasha.com/javascript-substring-function/76#comments</comments>
		<pubDate>Mon, 29 Dec 2008 17:43:45 +0000</pubDate>
		<dc:creator>Nischal Shetty</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[extract string javascript]]></category>
		<category><![CDATA[javascript substring]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[substring]]></category>
		<category><![CDATA[substring javascript]]></category>

		<guid isPermaLink="false">http://techtamasha.com/?p=76</guid>
		<description><![CDATA[Javascript has an inbuilt substring function which helps to extract parts of a string. substring(start, stop) : start (mandatory) &#8211; The starting index stop (optional) &#8211; The index to stop extraction Example: If you want to find the first 3 alphabets in the word INDIA, the code would be var name = &#8220;INDIA&#8221;; var firstThreeLetters [...]]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:100px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.techtamasha.com%2Fjavascript-substring-function%2F76&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:110px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Javascript Substring function" data-url="http://www.techtamasha.com/javascript-substring-function/76" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p><strong>Javascript</strong> has an inbuilt <strong>substring</strong> function which helps to extract parts of a string.</p>
<p>substring(start, stop) :</p>
<p><strong>start</strong> (<em>mandatory</em>) &#8211; The starting index</p>
<p><strong>stop</strong> (<em>optional</em>) &#8211; The index to stop extraction</p>
<p><span style="text-decoration: underline;">Example</span>: If you want to find the first 3 alphabets in the word <span style="color: #008000;">INDIA</span>, the code would be</p>
<blockquote><p>var name = &#8220;INDIA&#8221;;</p>
<p>var firstThreeLetters = name.substring(0,3);</p>
<p>alert(firstThreeLetters);</p></blockquote>
<p>The alert would display : <span style="color: #008000;">IND</span></p>
<p><span style="text-decoration: underline;">Note</span>: Here <span style="text-decoration: underline;"><em>start</em></span> is 0 hence the extraction starts from the letter in the 0th position i.e. the first letter. The <span style="text-decoration: underline;"><em>stop</em></span> index is 3 which means extraction would stop at index 3 (<span style="text-decoration: underline;">the letter at index 3 will not be extracted</span>)</p>
<p>Since <em><span style="text-decoration: underline;">stop</span></em> is optional, if you only specify the <em><span style="text-decoration: underline;">start</span></em> parameter, all the letters after the starting index (including the one at the start) would be extracted.</p>
<p><span style="text-decoration: underline;">Example</span>: Consider the same example as above, for the word <span style="color: #008000;">INDIA</span> if we were to give the <em><span style="text-decoration: underline;">start</span></em> as 1</p>
<blockquote><p>var name = &#8220;INDIA&#8221;;</p>
<p>var extractedLetters = name.substring(1);</p>
<p>alert(extractedLetters);</p></blockquote>
<p>The alert would display <span style="color: #008000;">NDIA</span> as the output of the javascript substring method.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<h2>Indepth Analysis of Javascript substring</h2>
<p>Let&#8217;s try and create our own Javascript substring function.</p>
<blockquote><p>String.prototype.mySubstring = function(start,stop) {</p>
<p>var charArray = this.split(&#8216;);</p>
<p>var temp = &#8220;&#8221;;</p>
<p>for(var i=start;&lt;stop;i++)</p>
<p>{</p>
<p>temp = temp + charArray[i];</p>
<p>}</p>
<p>return temp;</p>
<p>}</p></blockquote>
<p>Now, you can use this function instead of the default substring function. Include the above code in any page and you can use mySubstring inside any javascript function.</p>
<p><span style="text-decoration: underline;">Example</span>:</p>
<blockquote><p>var name = &#8220;INDIA&#8221;;</p>
<p>var extractedLetters = name.mySubstring(0,3);</p>
<p>alert(extractedLetters);</p></blockquote>
<p>The alert would display IND thus emulating the real Javascript substring function!</p>
<p><span style="text-decoration: underline;">Note</span>: This method is just a food for thought. To help you understand how exactly such methods would be implemented. For all practical purposes use the default substring function of Javascript.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.techtamasha.com/javascript-substring-function/76/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript email validation</title>
		<link>http://www.techtamasha.com/javascript-email-validation/47</link>
		<comments>http://www.techtamasha.com/javascript-email-validation/47#comments</comments>
		<pubDate>Mon, 05 May 2008 17:46:55 +0000</pubDate>
		<dc:creator>Nischal Shetty</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[email javascript]]></category>
		<category><![CDATA[email validation]]></category>
		<category><![CDATA[javascript email]]></category>
		<category><![CDATA[javascript email validation]]></category>
		<category><![CDATA[javascript regular expression]]></category>
		<category><![CDATA[regular expression]]></category>

		<guid isPermaLink="false">http://techtamasha.com/?p=47</guid>
		<description><![CDATA[This post will describe the javascript email validation. First and foremost, all apologies for such a long delay in writing a new post. I was kind of tied up with some work. But from now on I&#8217;ll try my best to be regular We will be using regular expression for email validation. And don&#8217;t you [...]]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:100px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.techtamasha.com%2Fjavascript-email-validation%2F47&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:110px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Javascript email validation" data-url="http://www.techtamasha.com/javascript-email-validation/47" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>This post will describe the <strong>javascript email validation</strong>.</p>
<p>First and foremost, all apologies for such a long delay in writing a new post. I was kind of tied up with some work. But from now on I&#8217;ll try my best to be regular <img src='http://www.techtamasha.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>We will be using regular expression for email validation. And don&#8217;t you worry. I&#8217;ll see to it that by the time you finish reading this post, you would have got a fair idea about Regular Expressions.</p>
<p>Lets try to construct the regular expression that we will be using to check the email   entered by the user.</p>
<p>Consider these two email id&#8217;s : example@example.com and exam_ple@ex.am.ple</p>
<p><span style="text-decoration: underline;">Quick references</span>:</p>
<p><strong>.</strong> (dot) matches any single character. Ex. &#8220;h.t&#8221; will match &#8220;hut&#8221;, &#8220;hot&#8221; etc.</p>
<p><strong>[ ]</strong> Brackets match a single character that is contained in the given expression. Ex. [a-d] will match &#8216;a&#8217; or &#8216;b&#8217; or &#8216;c&#8217; or &#8216;d&#8217;. Similarly, [a-cx-z] will match &#8216;a&#8217; or &#8216;b&#8217; or &#8216;c&#8217; or &#8216;x&#8217; or &#8216;y&#8217; or &#8216;z&#8217;.</p>
<p><strong>^</strong> Matches the starting position within the given string.</p>
<p><strong>$</strong> Matches the ending position of the given string.</p>
<p><strong>*</strong> Matches the <strong>preceding </strong>element zero or more times.</p>
<p><strong>+ </strong>Matches the <strong>preceding </strong>element one or more times.</p>
<p><strong>{n,m} </strong>Matches the occurrence of the previous symbol not less than <strong>n </strong>and not more than <strong>m </strong>times.</p>
<p><strong>\</strong> Its the escape character.  Ex. As shown above, .(dot) matches a single occurrence of any character. But what if we need to match an occurrence of (dot) itself. We write it as \.</p>
<p><span style="text-decoration: underline;">Considering the email id&#8217;s shown above, we can list our requirements as follows</span>:</p>
<p>1. Email Id needs to start with alphabets or numbers &#8211; regex will be  ^([a-zA-Z0-9])  i.e.  the email id should start with either an alphabet or a number.</p>
<p>2. It can contain any number of alphabets, numbers and a few special characters. RegEx will be  ([a-zA-Z0-9\.\_\-])*</p>
<p>3.  Then there should be the famous &#8216;@&#8217; symbol which we simply write as  @</p>
<p>4.  Then again any number of alphabets or numbers or &#8216;-&#8217; are allowed. RegEx is (([a-zA-Z0-9\-])+\.)+</p>
<p>5. Finally, the ending of the email  ([a-zA-Z]{2,4})+$</p>
<p><span style="text-decoration: underline;">Here&#8217;s the final regular expression for validating the email id&#8217;s</span> :</p>
<p>^([a-zA-Z0-9])([a-zA-Z0-9\.\_\-])*@(([a-zA-Z0-9])+(\.))+([a-zA-Z]{2,4})+$</p>
<p>Now, lets see how to use it in the javascript. We make use of the search() function of javascript.</p>
<p>function emailValidation(){</p>
<p>var emailRegEx = /^([a-zA-Z0-9])([a-zA-Z0-9\._-])*@(([a-zA-Z0-9])+(\.))+([a-zA-Z]{2,4})+$/ ;</p>
<p>var testMail = &#8220;example@example.com&#8221;;</p>
<p>if(testMail.search(emailRegEx)==-1)</p>
<p>alert(&#8220;Invalid&#8221;);</p>
<p>}</p>
<h3><a href="http://techtamasha.com/examples/emailValidation.html" target="_blank">Click Here to view the example</a>.</h3>
<p><strong>UPDATE 1 :</strong> Please use the regular expression shown below instead of the one above. This fixes the bug which allowed consecutive special charaters i.e. previously <strong>example..example@example.com</strong> was displayed as valid. It has been fixed now. Please do test the script before you plan to use it. If you find some problems in it then do let me know. I&#8217;ll try and fix it.</p>
<p><span style="font-family: Arial; color: black; font-size: x-small;"><span style="font-size: 10pt; color: #000000;"><span style="color: #ff0000;">var emailRegEx =  /^([a-zA-Z0-9])(([a-zA-Z0-9])*([\._-])?([a-zA-Z0-9]))*@(([a-zA-Z0-9\-])+(\.))+([a-zA-Z]{2,4})+$/;</span></span></span></p>
<p><strong>UPDATE 2:</strong> I&#8217;ve changed the regex a bit to allow email with &#8216;+&#8217; in them. So, test+example@example.com would be a valid email.</p>
<p><span style="color: #ff0000;">var emailRegEx = /^([a-zA-Z0-9])(([a-zA-Z0-9])*([\._\+-])*([a-zA-Z0-9]))*@(([a-zA-Z0-9\-])+(\.))+([a-zA-Z]{2,4})+$/;</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.techtamasha.com/javascript-email-validation/47/feed</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>JavaScript parseInt and parseFloat functions</title>
		<link>http://www.techtamasha.com/javascript-parseint-and-parsefloat-functions/44</link>
		<comments>http://www.techtamasha.com/javascript-parseint-and-parsefloat-functions/44#comments</comments>
		<pubDate>Fri, 04 Apr 2008 15:05:05 +0000</pubDate>
		<dc:creator>Nischal Shetty</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[javascript parseFloat]]></category>
		<category><![CDATA[javascript parseInt]]></category>
		<category><![CDATA[parseFloat]]></category>
		<category><![CDATA[parseInt]]></category>

		<guid isPermaLink="false">http://techtamasha.com/?p=44</guid>
		<description><![CDATA[If the Number() function was generic in nature then the parseInt() and parseFloat() functions will act to be more specific in what they do. parseInt() will parse the data into an integer value(if possible) and return the result. It returns &#8216;NaN&#8217; i.e. &#8216;Not a Number&#8217; if the data is unparseable. Similarly, parseFloat() parses float values. [...]]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:100px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.techtamasha.com%2Fjavascript-parseint-and-parsefloat-functions%2F44&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:110px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="JavaScript parseInt and parseFloat functions" data-url="http://www.techtamasha.com/javascript-parseint-and-parsefloat-functions/44" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>If the <a href="http://techtamasha.com/?p=39" target="_blank">Number()</a> function was generic in nature then the <strong>parseInt()</strong> and <strong>parseFloat()</strong> functions will act to be more specific in what they do.</p>
<p>parseInt() will parse the data into an integer value(if possible)  and return the result. It returns &#8216;NaN&#8217; i.e. &#8216;Not a Number&#8217; if the data is unparseable.</p>
<p>Similarly, parseFloat() parses float values.</p>
<p>Here are a few examples to help you understand these two functions better:</p>
<p>var a = &#8220;10&#8243;;</p>
<p>alert(parseInt(a));</p>
<p>alert(parseFloat(a));</p>
<p><strong>output</strong>:</p>
<p><strong>10</strong></p>
<p><strong>10</strong></p>
<p>a = &#8220;10.12&#8243;;</p>
<p>alert(parseInt(a));</p>
<p>alert(parseFloat(a));</p>
<p><strong>output</strong>:</p>
<p><strong>10</strong><br />
<strong><br />
10.12</strong></p>
<p>a = &#8221;  10.25 as you can see, white spaces are allowed and also alphabets after the number&#8221;</p>
<p>alert(parseInt(a));</p>
<p>alert(parseFloat(a));<br />
<strong><br />
output</strong>:</p>
<p><strong>10</strong><br />
<strong><br />
10.25</strong></p>
<p>a = &#8221; nope this is wrong, wont work 100.24&#8243;;</p>
<p>alert(parseInt(a));</p>
<p>alert(parseFloat(a));<br />
<strong><br />
output</strong>:</p>
<p><strong>NaN</strong></p>
<p><strong>NaN</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.techtamasha.com/javascript-parseint-and-parsefloat-functions/44/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>&#8216;indexOf&#8217; or &#8216;contains&#8217; function for Javascript</title>
		<link>http://www.techtamasha.com/indexof-or-contains-function-for-javascript/42</link>
		<comments>http://www.techtamasha.com/indexof-or-contains-function-for-javascript/42#comments</comments>
		<pubDate>Tue, 01 Apr 2008 12:31:07 +0000</pubDate>
		<dc:creator>Nischal Shetty</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://techtamasha.com/?p=42</guid>
		<description><![CDATA[The thought of elaborating on the &#8220;contains&#8221; function for JavaScript occurred to me while I was writing my previous post . From what I know, JavaScript doesn&#8217;t seem to have a function to allow the user to check if a particular letter exists in the given data. But, it does have an indexOf() function that [...]]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:100px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.techtamasha.com%2Findexof-or-contains-function-for-javascript%2F42&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:110px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="&#8216;indexOf&#8217; or &#8216;contains&#8217; function for Javascript" data-url="http://www.techtamasha.com/indexof-or-contains-function-for-javascript/42" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>The thought of elaborating on the &#8220;contains&#8221; function for JavaScript occurred to me while I was writing my <font color="#ff9900"><a href="http://techtamasha.com/?p=5">previous post</a></font> . From what I know, JavaScript doesn&#8217;t seem to have a function to allow the user to check if a particular letter exists in the given data.</p>
<p>But, it does have an <strong>indexOf() </strong>function that might just do the trick <img src='http://www.techtamasha.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>All you need to do is check whether the return value is -1 or not. A return value of -1 implies that the specific letter is not present in the given data.</p>
<p>A simple example below will make things clear:</p>
<p>function checkIndexOf()<br />
{<br />
var a = &#8220;hello&#8221;;</p>
<p>alert(a.indexOf(&#8216;l&#8217;));<br />
alert(a.indexOf(&#8216;E&#8217;));<br />
alert(a.indexOf(&#8217;0&#8242;));</p>
<p>}</p>
<p>The output is as follows:</p>
<p>2   // which implies that the letter &#8216;l&#8217; is present in position 2.</p>
<p>-1  //which implies that the letter &#8216;E&#8217; is not present.(JavaScript is case sensitive)</p>
<p>-1  //which implies that the number 0 is not present.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.techtamasha.com/indexof-or-contains-function-for-javascript/42/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Javascript isNaN()</title>
		<link>http://www.techtamasha.com/javascript-isnan/5</link>
		<comments>http://www.techtamasha.com/javascript-isnan/5#comments</comments>
		<pubDate>Mon, 31 Mar 2008 15:55:44 +0000</pubDate>
		<dc:creator>Nischal Shetty</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[javascript check numeric field]]></category>
		<category><![CDATA[javascript isNaN()]]></category>
		<category><![CDATA[javascript validate numeric]]></category>
		<category><![CDATA[not a number function javascript]]></category>

		<guid isPermaLink="false">http://techtamasha.com/?p=5</guid>
		<description><![CDATA[The isNaN() function is used to check if the data contained in the Javascript variable is a number or not. The function returns true if the data is not a number and false if the data is a number. This function is of great help while performing javascript validation to check if a user has [...]]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:100px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.techtamasha.com%2Fjavascript-isnan%2F5&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:110px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Javascript isNaN()" data-url="http://www.techtamasha.com/javascript-isnan/5" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>The <strong>isNaN()</strong> function is used to check if the data contained in the Javascript variable is a number or not. The function returns <strong>true</strong> if the data is <strong>not a number</strong> and <strong>false</strong> if the data is a <strong>number</strong>.</p>
<p>This function is of great help while performing javascript validation to check if a user has entered only numeric values into the textboxes as specified by you.</p>
<p>Here is an example:</p>
<p>var a = &#8220;hi&#8221;;</p>
<p>var b = &#8220;123&#8243;;</p>
<p>if(isNaN(a))</p>
<p>{</p>
<p>alert(&#8220;Variable &#8216;a&#8217; is not a number.&#8221;);</p>
<p>}</p>
<p>if(isNaN(b))</p>
<p>{</p>
<p>alert(&#8220;Variable &#8216;b&#8217; is not a number.&#8221;);</p>
<p>}</p>
<p>The output will be &#8220;Variable &#8216;a&#8217; is not a number.&#8221;</p>
<p><strong>A note to remember</strong>: &#8220;isNaN() &#8221; will return false for &#8220;1e1&#8243; .</p>
<p>I mean, if you have numeric data with the letter &#8216;e&#8217; in it, then the data is still considered to be numeric!</p>
<p>why is that?</p>
<p>Well, cause it treats the value to be exponential. So if you plan to validate for a numeric field and do not want to allow the letter &#8216;e&#8217; then remember to validate it separately.</p>
<p>Well, as far as validating &#8216;e&#8217; is considered&#8230; I wonder how you do that in Javascript!!</p>
<p>I mean we need to have a function which will tell us if a particular letter exists in a given data. Hmmmm&#8230; Donno if there exists a function like that in javascript. My next post will be on this <img src='http://www.techtamasha.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.techtamasha.com/javascript-isnan/5/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to perform mathematical operations in javascript?</title>
		<link>http://www.techtamasha.com/how-to-perform-mathematical-operations-in-javascript/39</link>
		<comments>http://www.techtamasha.com/how-to-perform-mathematical-operations-in-javascript/39#comments</comments>
		<pubDate>Fri, 28 Mar 2008 13:18:29 +0000</pubDate>
		<dc:creator>Nischal Shetty</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[add subtract in javascript]]></category>
		<category><![CDATA[Javascript ADD]]></category>
		<category><![CDATA[javascript math]]></category>
		<category><![CDATA[mathematical operations]]></category>

		<guid isPermaLink="false">http://techtamasha.com/?p=39</guid>
		<description><![CDATA[You might come across a situation wherein you need to perform some mathematical operations on the data entered by the user. Be it addition, subtraction , multiplication or division, you can do these calculations using Javascript easily. Since all the variables in JavaScript are declared using &#8216;var&#8217; as a datatype, we need to use a [...]]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:100px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.techtamasha.com%2Fhow-to-perform-mathematical-operations-in-javascript%2F39&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:110px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="How to perform mathematical operations in javascript?" data-url="http://www.techtamasha.com/how-to-perform-mathematical-operations-in-javascript/39" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>You might come across a situation wherein you need to perform some mathematical operations on the data entered by the user. Be it addition, subtraction , multiplication or division, you can do these calculations using Javascript easily.</p>
<p>Since all the variables in JavaScript are declared using &#8216;var&#8217; as a datatype, we need to use a function to tell Javascript to treat the contents of the variable as a number on which calculations have to be performed.</p>
<p>All you need to do is to use the &#8216;Number()&#8217; function.</p>
<p>The example below will make things clear for you :</p>
<p>var a = &#8220;5&#8243;;</p>
<p>var b = &#8220;5&#8243;;</p>
<p>var result = a + b;</p>
<p>alert(&#8220;The result is &#8220;+result);  // This will give you an output of 55 and not 10.</p>
<p>var calculatedResult = Number(a) + Number(b);</p>
<p>alert(&#8220;The mathematical result is &#8220;+calculatedResult); //This will give the result as 10.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.techtamasha.com/how-to-perform-mathematical-operations-in-javascript/39/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Disable(readOnly) and Enable textbox using JavaScript</title>
		<link>http://www.techtamasha.com/disablereadonly-and-enable-textbox-using-javascript/34</link>
		<comments>http://www.techtamasha.com/disablereadonly-and-enable-textbox-using-javascript/34#comments</comments>
		<pubDate>Thu, 28 Feb 2008 11:34:53 +0000</pubDate>
		<dc:creator>Nischal Shetty</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://techtamasha.com/?p=34</guid>
		<description><![CDATA[The following is a short example of a code that will enabledisable a textbox at the click of a button : &#60;html&#62; &#60;script&#62; function enableDisable() { //This will get the HTML content of the current page var form = document.testEnableDisable; //The if condition checks for the value of the button. if(form.enableDisableButton.value==&#8221;Disable&#8221;) { //If button value [...]]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:100px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.techtamasha.com%2Fdisablereadonly-and-enable-textbox-using-javascript%2F34&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:110px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Disable(readOnly) and Enable textbox using JavaScript" data-url="http://www.techtamasha.com/disablereadonly-and-enable-textbox-using-javascript/34" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>The following is a short example of a code that will enabledisable a textbox at the click of a button :</p>
<p>&lt;html&gt;</p>
<p>&lt;script&gt;</p>
<p>function enableDisable()</p>
<p>{</p>
<p>//This will get the HTML content of the current page</p>
<p>var form = document.testEnableDisable;</p>
<p>//The if condition checks for the value of the button.</p>
<p>if(form.enableDisableButton.value==&#8221;Disable&#8221;)<br />
{</p>
<p>//If button value is &#8216;Disable&#8217; then the textbox is made readOnly</p>
<p>form.textBox1.readOnly = true;</p>
<p>//The button value is changed to &#8216;Enable&#8217;</p>
<p>form.enableDisableButton.value=&#8221;Enable&#8221;</p>
<p>}</p>
<p>else</p>
<p>{</p>
<p>form.textBox1.readOnly = false;</p>
<p>form.enableDisableButton.value=&#8221;Disable&#8221;</p>
<p>}</p>
<p>}</p>
<p>&lt;/script&gt;</p>
<p>&lt;body&gt;</p>
<p>&lt;form name= &#8220;testEnableDisable&#8221;&gt;</p>
<p>&lt;input type = &#8220;text&#8221; id = &#8220;textBox1&#8243; value=&#8221;Enabled&#8221;&gt;</p>
<p>&lt;input type=&#8221;button&#8221; id=&#8221;enableDisableButton&#8221; onClick=&#8221;enableDisable()&#8221; value=&#8221;Disable&#8221;&gt;</p>
<p>&lt;/body&gt;</p>
<p>&lt;/form&gt;</p>
<p>&lt;/html&gt;</p>
<p>Basically, its the readOnly value of the text box that needs to be changed using JavaScript.</p>
<p><strong>Note:</strong> <strong>JavaScript </strong>is <strong>case sensitive</strong> and hence <strong>&#8216;readonly&#8217;</strong> will not give you the right result&#8230;<strong>&#8216;O&#8217;</strong> should be in <strong>capital</strong>&#8230;<strong>&#8216;readOnly&#8217;</strong> when you use it in JavaScript.</p>
<p><span style="color: #800000;"><a href="http://techtamasha.com/examples/enabledisable.html" target="_blank">Click here to view the example</a></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.techtamasha.com/disablereadonly-and-enable-textbox-using-javascript/34/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Allow Users to enter data into Message Box(Javascript Prompt)</title>
		<link>http://www.techtamasha.com/allow-users-to-enter-data-into-message-boxjavascript-prompt/33</link>
		<comments>http://www.techtamasha.com/allow-users-to-enter-data-into-message-boxjavascript-prompt/33#comments</comments>
		<pubDate>Thu, 28 Feb 2008 07:56:30 +0000</pubDate>
		<dc:creator>Nischal Shetty</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://techtamasha.com/?p=33</guid>
		<description><![CDATA[Javascript has a function named &#8216;prompt&#8217; which displays a message box along with a text box in it which allows users to input data. Here&#8217;s how you achieve it : function testPrompt() { var enteredData = prompt(&#8220;Type something in the text box below&#8221;,&#8221;"); alert(&#8220;You entered &#8220;+enteredData); } prompt() takes two parameters. The first parameter is [...]]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:100px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.techtamasha.com%2Fallow-users-to-enter-data-into-message-boxjavascript-prompt%2F33&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:110px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Allow Users to enter data into Message Box(Javascript Prompt)" data-url="http://www.techtamasha.com/allow-users-to-enter-data-into-message-boxjavascript-prompt/33" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>Javascript has a function named &#8216;prompt&#8217; which displays a message box along with a text box in it which allows users to input data.</p>
<p>Here&#8217;s how you achieve it :</p>
<p>function testPrompt()</p>
<p>{</p>
<p>var enteredData = prompt(&#8220;Type something in the text box below&#8221;,&#8221;");</p>
<p>alert(&#8220;You entered &#8220;+enteredData);</p>
<p>}</p>
<p>prompt() takes two parameters. The first parameter is used to display the message above the text box whereas the second parameter fills up the textbox with the values you specify(leave it blank if you want the text box to be empty)</p>
<p>To get a quick glimpse of the promt box copy paste the code below into your browser address bar and press enter :</p>
<p><strong>Note</strong>: you&#8217;ll have to manually replace the double quotes(with double quotes again) after you copy paste the code due to the formatting in this page</p>
<p>javascript:var s = prompt(&#8220;Type something in the text box below&#8221;,&#8221;");alert(s);</p>
]]></content:encoded>
			<wfw:commentRss>http://www.techtamasha.com/allow-users-to-enter-data-into-message-boxjavascript-prompt/33/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Convert DOM to String</title>
		<link>http://www.techtamasha.com/convert-dom-to-string/29</link>
		<comments>http://www.techtamasha.com/convert-dom-to-string/29#comments</comments>
		<pubDate>Fri, 15 Feb 2008 06:58:25 +0000</pubDate>
		<dc:creator>Nischal Shetty</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://techtamasha.com/?p=29</guid>
		<description><![CDATA[While working on one of my projects I came across a scenario where I needed to convert the DOM object into a String representation to send it as an AJAX request parameter. The way to do this is as follows: Suppose you have a form named &#8220;Test&#8221;. We first get the DOM object of the [...]]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:100px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.techtamasha.com%2Fconvert-dom-to-string%2F29&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:110px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Convert DOM to String" data-url="http://www.techtamasha.com/convert-dom-to-string/29" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>While working on one of my projects I came across a scenario where I needed to convert the DOM object into a String representation to send it as an AJAX request parameter.</p>
<p>The way to do this is as follows:</p>
<p>Suppose you have a form named &#8220;Test&#8221;.</p>
<p>We first get the DOM object of the current page as follows:</p>
<p>var domObject = document.Test;</p>
<p>//Now lets convert this DOM to String</p>
<p>var domToString = domObject.innerHTML;</p>
<p>Thats it!!! Put an alert and you&#8217;ll see the complete DOM in a string representation.</p>
<p>alert(domToString);</p>
]]></content:encoded>
			<wfw:commentRss>http://www.techtamasha.com/convert-dom-to-string/29/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

