<?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>Theme Heven &#187; JavaScript</title>
	<atom:link href="http://www.themeheven.com/category/tutorial/javascript-tutorial/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.themeheven.com</link>
	<description>WordPress, Ajax, Jquery, Web 2.0, PHP, Tutorials, Tips, Tricks</description>
	<lastBuildDate>Wed, 13 Jan 2010 09:37:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>JavaScript Built in Object, Method, Properties &amp; Handling Events in browser</title>
		<link>http://www.themeheven.com/2009/08/javascript-built-in-object-method-properties-handling-events-in-browser/</link>
		<comments>http://www.themeheven.com/2009/08/javascript-built-in-object-method-properties-handling-events-in-browser/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 06:23:43 +0000</pubDate>
		<dc:creator>themeheven</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.themeheven.com/?p=259</guid>
		<description><![CDATA[JavaScript is an Object Oriented Programming Language. It  is completely centered around objects. May if you are newer you have question about What is an object? so the very short answer is everything is object.
In the context of a web page, a JavaScript object is any scriptable HTML element &#8211; that is any HTML [...]]]></description>
			<content:encoded><![CDATA[<p>JavaScript is an Object Oriented Programming Language. It  is completely centered around objects. May if you are newer you have question about What is an object? so the very short answer is everything is <em>object</em>.</p>
<p>In the context of a web page, a JavaScript object is any scriptable HTML element &#8211; that is any HTML element within a document that may be accessed through the JavaScript language. Scriptable HTML elements are associated with the Document Object Model, also known as the DOM.</p>
<p><strong>Object:</strong></p>
<p>In JavaScript, you interact with the browser throught the use of built in <em>objects</em>; these objects exist already, and can be accessed from your JavaScript code by name. The built-in objects are Date, Math, String, Array, and Object. Each is used in a unique and not-quite-consistent way. Objects have properties, which you can think of as characteristics of an object. Here are the four most commoly used objects:</p>
<p><strong>1. The String Object:</strong></p>
<p>The String object is used to manipulate a stored piece of text. The String object of JavaScript allows you to perform manipulations on a stored piece of text, such as extracting a substring, searching for the occurrence of a certain character within it etc. General method of using String Object is to declare a variable and assign a string, in other words a text to the variable.</p>
<p>String Object Properties:</p>
<p><em>length</em> &#8211; The number of characters in the string. (# characters)</p>
<p><em>prototype</em> &#8211; For creating more properties</p>
<p>String Object Methods for HTML Formatting:</p>
<table border="0" cellspacing="0" cellpadding="4">
<tbody>
<tr bgcolor="#cccccc">
<td width="129" valign="top">
<p align="center"><strong> Method Name</strong></p>
</td>
<td width="346" valign="top">
<p align="center"><strong> Returned Value</strong></p>
</td>
</tr>
<tr>
<td width="129" valign="top">anchor</td>
<td width="346" valign="top">&lt;A NAME=&#8221;anchortext&#8221;&gt;foo&lt;/A&gt;</td>
</tr>
<tr>
<td width="129" valign="top">big</td>
<td width="346" valign="top">&lt;BIG&gt;foo&lt;/BIG&gt;</td>
</tr>
<tr>
<td width="129" valign="top">blink</td>
<td width="346" valign="top">&lt;BLINK&gt;foo&lt;/BLINK&gt;</td>
</tr>
<tr>
<td width="129" valign="top">bold</td>
<td width="346" valign="top">&lt;B&gt;foo&lt;/B&gt;</td>
</tr>
<tr>
<td width="129" valign="top">fixed</td>
<td width="346" valign="top">&lt;TT&gt;foo&lt;/TT&gt;</td>
</tr>
<tr>
<td width="129" valign="top">fontcolor</td>
<td width="346" valign="top">&lt;FONT COLOR=&#8221;green&#8221;&gt;foo&lt;/</td>
</tr>
<tr>
<td width="129" valign="top">fontsize</td>
<td width="346" valign="top">&lt;FONT SIZE=&#8221;-1&#8243;&gt;foo&lt;/FONT&gt;</td>
</tr>
<tr>
<td width="129" valign="top">italics</td>
<td width="346" valign="top">&lt;I&gt;foo&lt;/I&gt;</td>
</tr>
<tr>
<td width="129" valign="top">link</td>
<td width="346" valign="top">&lt;A HREF=&#8221;linktext&#8221;&gt;foo&lt;/A&gt;</td>
</tr>
<tr>
<td width="129" valign="top">small</td>
<td width="346" valign="top">&lt;SMALL&gt;foo&lt;/SMALL&gt;</td>
</tr>
<tr>
<td width="129" valign="top">strike</td>
<td width="346" valign="top">&lt;STRIKE&gt;foo&lt;/STRIKE&gt;</td>
</tr>
<tr>
<td width="129" valign="top">sub</td>
<td width="346" valign="top">&lt;SUB&gt;foo&lt;/SUB&gt;</td>
</tr>
<tr>
<td width="129" valign="top">sup</td>
<td width="346" valign="top">&lt;SUP&gt;foo&lt;/SUP&gt;</td>
</tr>
<tr>
<td width="129" valign="top">toLowerCase</td>
<td width="346" valign="top">uppercase</td>
</tr>
<tr>
<td width="129" valign="top">toUpperCase</td>
<td width="346" valign="top">UPPERCASE</td>
</tr>
</tbody>
</table>
<p><a href="http://www.javascriptkit.com/jsref/string.shtml" target="_blank">See more methods</a></p>
<p><strong>2. The Math Object : </strong></p>
<p>The Math object allows you to perform mathematical tasks. The JavaScript math object can be invoked without creating an instance of it. But unlike the String and the Date object which requires defining the object, Math object need not be defined. So in conclusion The Math object of JavaScript allows you to perform certain calculations by using method functions of the Math object.</p>
<p>JavaScript Math Object Properties:</p>
<p><em>E</em> &#8211; Euler&#8217;s constant</p>
<p><em>LN2</em> &#8211; Natural log of 2</p>
<p><em>LN10</em> &#8211; Natural log of 10</p>
<p><em>LOG2E</em> &#8211;  Base 2 logarithm of E.</p>
<p><em>LOG10E</em> &#8211;  Base 10 logarithm of E.</p>
<p><em>PI</em> &#8211;  Value of Pi</p>
<p><em>SQRT1_2</em> &#8211; Square root of 1/2.</p>
<p><em>SQRT2</em> &#8211; Square root of 2</p>
<p>Math Object Method:</p>
<table border="0" cellspacing="0" cellpadding="4">
<tbody>
<tr bgcolor="#cccccc">
<td valign="top">
<p align="center"><strong> Method</strong></p>
</td>
<td valign="top">
<p align="center"><strong> Description</strong></p>
</td>
</tr>
<tr>
<td valign="top">abs(a)</td>
<td valign="top">Supplies the absolute value of a number</td>
</tr>
<tr>
<td valign="top">acos(a)</td>
<td valign="top">Supplies the arccosine of a number</td>
</tr>
<tr>
<td valign="top">asin(a)</td>
<td valign="top">Supplies the arcsine of a number</td>
</tr>
<tr>
<td valign="top">atan(a)</td>
<td valign="top">Supplies the arctangent of a as a numeric value between -PI/2 and PI/2 radians</td>
</tr>
<tr>
<td valign="top">atan2(a,b)</td>
<td valign="top">Supplies the angle theta of a point as a numeric value between -PI and PI radians</td>
</tr>
<tr>
<td valign="top">ceil(a)</td>
<td valign="top">Supplies the value of a number rounded up to the nearest number</td>
</tr>
<tr>
<td valign="top">cos(a)</td>
<td valign="top">Supplies the cosine of a number</td>
</tr>
<tr>
<td valign="top">exp(a)</td>
<td valign="top">Supplies the exponential value of a number</td>
</tr>
<tr>
<td valign="top">floor(a)</td>
<td valign="top">Supplies the value of a number rounded down to the nearest number</td>
</tr>
<tr>
<td valign="top">log(a)</td>
<td valign="top">Supplies the logarithm of a number</td>
</tr>
<tr>
<td valign="top">max(a,b)</td>
<td valign="top">Supplies the number with the highest value</td>
</tr>
<tr>
<td valign="top">min(a,b)</td>
<td valign="top">Supplies the number with the lowest value</td>
</tr>
<tr>
<td valign="top">pow(a,b)</td>
<td valign="top">Supplies the value of one number (a) to the power of the second number (b)</td>
</tr>
<tr>
<td valign="top">random( )</td>
<td valign="top">Supplies a random number between 0 and 9</td>
</tr>
<tr>
<td valign="top">round(a)</td>
<td valign="top">Supplies a number rounded to the nearest number</td>
</tr>
<tr>
<td valign="top">sin(a)</td>
<td valign="top">Supplies the sine of a number</td>
</tr>
<tr>
<td valign="top">sqrt(a)</td>
<td valign="top">Supplies the square root of a number</td>
</tr>
<tr>
<td valign="top">tan(a)</td>
<td valign="top">Supplies the tangent of an angle</td>
</tr>
<tr>
<td valign="top">toSource(a)</td>
<td valign="top">Refers to the source code of an object</td>
</tr>
<tr>
<td valign="top">valueOf( )</td>
<td valign="top">Supplies the primitive value of a math object</td>
</tr>
</tbody>
</table>
<p><strong>3. The Date Object: </strong></p>
<p>The Date object is used to work with dates and times. Generally in web page the Date object provides information about the current date and time on the client&#8217;s machine. The Date object is similar to the String object in that you create new instances of the object when you assign it to a variable. It differs from the String object in that you use a statement called new to create it.</p>
<p>JavaScript Date Object Properties:</p>
<p><em>constructor</em> &#8211;  Returns a reference to the Date function that created the object .</p>
<p><em>prototype</em> &#8211; Allows you to add properties and methods to the object.</p>
<p>Instantiating a date object:</p>
<p><em>new Date()</p>
<p>new Date(milliseconds)</p>
<p>new Date(dateString)</p>
<p>new Date(year, month, day, hours, minutes, seconds, milliseconds) </em></p>
<p>JavaScript Date Object Properties:</p>
<table border="0" cellspacing="0" cellpadding="4">
<tbody>
<tr bgcolor="#cccccc">
<td width="17%"><strong> Method </strong></td>
<td width="83%"><strong> Description </strong></td>
</tr>
<tr>
<td valign="top">Date()</td>
<td valign="top">Returns today&#8217;s date and time</td>
</tr>
<tr>
<td valign="top">getDate()</td>
<td valign="top">Returns the day of the month from a Date object (from 1-31)</td>
</tr>
<tr>
<td valign="top">getDay()</td>
<td valign="top">Returns the day of the week from a Date object (from 0-6)</td>
</tr>
<tr>
<td valign="top">getMonth()</td>
<td valign="top">Returns the month from a Date object (from 0-11)</td>
</tr>
<tr>
<td valign="top">getFullYear()</td>
<td valign="top">Returns the year, as a four-digit number, from a Date object</td>
</tr>
<tr>
<td valign="top">getYear()</td>
<td valign="top">Returns the year, as a two-digit or a four-digit number, from a Date object. Use getFullYear() instead !!</td>
</tr>
<tr>
<td valign="top">getHours()</td>
<td valign="top">Returns the hour of a Date object (from 0-23)</td>
</tr>
<tr>
<td valign="top">getMinutes()</td>
<td valign="top">Returns the minutes of a Date object (from 0-59)</td>
</tr>
<tr>
<td valign="top">getSeconds()</td>
<td valign="top">Returns the seconds of a Date object (from 0-59)</td>
</tr>
<tr>
<td valign="top">getMilliseconds()</td>
<td valign="top">Returns the milliseconds of a Date object (from 0-999)</td>
</tr>
<tr>
<td valign="top">getTime()</td>
<td valign="top">Returns the number of milliseconds since midnight Jan 1, 1970</td>
</tr>
<tr>
<td valign="top">getTimezoneOffset()</td>
<td valign="top">Returns the difference in minutes between local time and Greenwich Mean Time (GMT)</td>
</tr>
<tr>
<td valign="top">getUTCDate()</td>
<td valign="top">Returns the day of the month from a Date object according to universal time (from 1-31)</td>
</tr>
<tr>
<td valign="top">getUTCDay()</td>
<td valign="top">Returns the day of the week from a Date object according to universal time (from 0-6)</td>
</tr>
<tr>
<td valign="top">getUTCMonth()</td>
<td valign="top">Returns the month from a Date object according to universal time (from 0-11)</td>
</tr>
<tr>
<td valign="top">getUTCFullYear()</td>
<td valign="top">Returns the four-digit year from a Date object according to universal time</td>
</tr>
<tr>
<td valign="top">getUTCHours()</td>
<td valign="top">Returns the hour of a Date object according to universal time (from 0-23)</td>
</tr>
<tr>
<td valign="top">getUTCMinutes()</td>
<td valign="top">Returns the minutes of a Date object according to universal time (from 0-59)</td>
</tr>
<tr>
<td valign="top">getUTCSeconds()</td>
<td valign="top">Returns the seconds of a Date object according to universal time (from 0-59)</td>
</tr>
<tr>
<td valign="top">getUTCMilliseconds()</td>
<td valign="top">Returns the milliseconds of a Date object according to universal time (from 0-999)</td>
</tr>
<tr>
<td valign="top">parse()</td>
<td valign="top">Takes a date string and returns the number of milliseconds since midnight of January 1, 1970</td>
</tr>
<tr>
<td valign="top">setDate()</td>
<td valign="top">Sets the day of the month in a Date object (from 1-31)</td>
</tr>
<tr>
<td valign="top">setMonth()</td>
<td valign="top">Sets the month in a Date object (from 0-11)</td>
</tr>
<tr>
<td valign="top">setFullYear()</td>
<td valign="top">Sets the year in a Date object (four digits)</td>
</tr>
<tr>
<td valign="top">setYear()</td>
<td valign="top">Sets the year in the Date object (two or four digits). Use setFullYear() instead !!</td>
</tr>
<tr>
<td valign="top">setHours()</td>
<td valign="top">Sets the hour in a Date object (from 0-23)</td>
</tr>
<tr>
<td valign="top">setMinutes()</td>
<td valign="top">Set the minutes in a Date object (from 0-59)</td>
</tr>
<tr>
<td valign="top">setSeconds()</td>
<td valign="top">Sets the seconds in a Date object (from 0-59)</td>
</tr>
<tr>
<td valign="top">setMilliseconds()</td>
<td valign="top">Sets the milliseconds in a Date object (from 0-999)</td>
</tr>
<tr>
<td valign="top">setTime()</td>
<td valign="top">Calculates a date and time by adding or subtracting a specified number of milliseconds to/from midnight January 1, 1970</td>
</tr>
<tr>
<td valign="top">setUTCDate()</td>
<td valign="top">Sets the day of the month in a Date object according to universal time (from 1-31)</td>
</tr>
<tr>
<td valign="top">setUTCMonth()</td>
<td valign="top">Sets the month in a Date object according to universal time (from 0-11)</td>
</tr>
<tr>
<td valign="top">setUTCFullYear()</td>
<td valign="top">Sets the year in a Date object according to universal time (four digits)</td>
</tr>
<tr>
<td valign="top">setUTCHours()</td>
<td valign="top">Sets the hour in a Date object according to universal time (from 0-23)</td>
</tr>
<tr>
<td valign="top">setUTCMinutes()</td>
<td valign="top">Set the minutes in a Date object according to universal time (from 0-59)</td>
</tr>
<tr>
<td valign="top">setUTCSeconds()</td>
<td valign="top">Set the seconds in a Date object according to universal time (from 0-59)</td>
</tr>
<tr>
<td valign="top">setUTCMilliseconds()</td>
<td valign="top">Sets the milliseconds in a Date object according to universal time (from 0-999)</td>
</tr>
<tr>
<td valign="top">toSource()</td>
<td valign="top">Represents the source code of an object</td>
</tr>
<tr>
<td valign="top">toString()</td>
<td valign="top">Converts a Date object to a string</td>
</tr>
<tr>
<td valign="top">toGMTString()</td>
<td valign="top">Converts a Date object, according to Greenwich time, to a string. Use toUTCString() instead !!</td>
</tr>
<tr>
<td valign="top">toUTCString()</td>
<td valign="top">Converts a Date object, according to universal time, to a string</td>
</tr>
<tr>
<td valign="top">toLocaleString()</td>
<td valign="top">Converts a Date object, according to local time, to a string</td>
</tr>
<tr>
<td valign="top">UTC()</td>
<td valign="top">Takes a date and returns the number of milliseconds since midnight of January 1, 1970 according to universal time</td>
</tr>
<tr>
<td valign="top">valueOf()</td>
<td valign="top">Returns the primitive value of a Date object</td>
</tr>
</tbody>
</table>
<h3>JavaScript Object, Method, propeties for Ajax:</h3>
<ul>
<li>history: Represents the list of URLs that the browser had already been to.</li>
<li>window: Represents the browser itself.</li>
<li>XMLHttpRequest: The object that you use in Ajax to communicate with the server.</li>
</ul>
<p>In JavaScript, Objects have methods and properties. A <em>method</em> is a chunk of code built into the object that performs some action. For example: you use the document object&#8217;s write method, which you access as document.write, to write to the document (in the current web page).</p>
<ul>
<li>document.write: Lets you write text to the current web page</li>
<li>history.go: Moves the browser to a page in the browser&#8217;s history</li>
<li>window.open: Opens a new browser window</li>
</ul>
<p><em>Properties,</em> on the other hand, are just settings that you can place data into. JavaScript properties often take their names from the attributes of HTML elements, such as the bgcolor attribute of the &lt;body&gt; element.</p>
<ul>
<li>document.bgcolor: Holds the background color of the current page.</li>
<li>document.fgcolor: Holds the foreground color of the current page.</li>
<li>document.lastmodified: Holds the data the page was last modified.</li>
<li>document.title: Holds the title of the page</li>
<li>location.hostname: Holds the name of the page&#8217;s host.</li>
<li>navigator.appName: Holds the type of the browser</li>
</ul>
<h3>See Also Following Topics:</h3>
<ul class="related_post">
<li><a href="http://www.themeheven.com/2009/05/various-method-javascript-form-validation/" title="Various Method JavaScript Form Validation">Various Method JavaScript Form Validation</a></li>
<li><a href="http://www.themeheven.com/2009/04/javascript-effect/" title="Javascript Effect">Javascript Effect</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.themeheven.com/2009/08/javascript-built-in-object-method-properties-handling-events-in-browser/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Various Method JavaScript Form Validation</title>
		<link>http://www.themeheven.com/2009/05/various-method-javascript-form-validation/</link>
		<comments>http://www.themeheven.com/2009/05/various-method-javascript-form-validation/#comments</comments>
		<pubDate>Fri, 08 May 2009 05:15:20 +0000</pubDate>
		<dc:creator>themeheven</dc:creator>
				<category><![CDATA[HOW TO]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Form Validation]]></category>

		<guid isPermaLink="false">http://www.themeheven.com/?p=169</guid>
		<description><![CDATA[This how-to will show you how to create a JavaScript-enabled form that checks whether a user has filled in the form correctly before it&#8217;s sent to the server. This is called form validation. First we&#8217;ll explain why form validation is a useful thing, and then build up a simple example form, explaining things as we [...]]]></description>
			<content:encoded><![CDATA[<p>This how-to will show you how to create a JavaScript-enabled form that checks whether a user has filled in the form correctly before it&#8217;s sent to the server. This is called form validation. First we&#8217;ll explain why form validation is a useful thing, and then build up a simple example form, explaining things as we go along. At the end, there&#8217;s a little exercise to keep you busy too!</p>
<h2>What is form validation?</h2>
<p>Form validation is the process of checking that a form has been filled in correctly before it is processed. For example, if your form has a box for the user to type their email address, you might want your form handler to check that they&#8217;ve filled in their address before you deal with the rest of the form.</p>
<p>There are two main methods for validating forms: server-side (using CGI scripts, ASP, etc), and client-side (usually done using JavaScript). Server-side validation is more secure but often more tricky to code, whereas client-side (JavaScript) validation is easier to do and quicker too (the browser doesn&#8217;t have to connect to the server to validate the form, so the user finds out instantly if they&#8217;ve missed out that required field!).</p>
<p><img src="http://www.elated.com/res/Image/articles/development/javascript/form-validation-with-javascript/client_side.gif" alt="" /></p>
<p>Client-side form validation (usually with JavaScript embedded in the Web page)</p>
<p><img src="http://www.elated.com/res/Image/articles/development/javascript/form-validation-with-javascript/server_side.gif" alt="" /></p>
<p>Server-side form validation (usually performed by a CGI or ASP script)</p>
<p>In this how-to we&#8217;ll build a simple form with client-side JavaScript validation. You can then adapt this form to your own requirements.</p>
<p>Source:<a href="http://www.elated.com/articles/form-validation-with-javascript/" target="_blank">ELATED</a></p>
<p>JavaScript can be used to validate data in HTML forms before sending off the content to a server.</p>
<p>Form data that typically are checked by a JavaScript could be:</p>
<ul>
<li> has the user left required fields empty?</li>
<li> has the user entered a valid e-mail address?</li>
<li> has the user entered a valid date?</li>
<li> has the user entered text in a numeric field?</li>
</ul>
<p><strong>Required Fields</strong></p>
<p>The function below checks if a required field has been left empty. If the required field is blank, an alert box alerts a message and the function returns false. If a value is entered, the function returns true (means that data is OK):</p>
<pre><code>function validate_required(field,alerttxt)

  {

  with (field)

{

if (value==null||value=="")

{

alert(alerttxt);return false;

}

else

{

return true;

}

}

}</code></pre>
<p>The entire script, with the HTML form could look something like this:</p>
<pre><code>&lt;html&gt;
&lt;head&gt;
&lt;script type="text/javascript"&gt;
function validate_required(field,alerttxt)
{
with (field)
  {
  if (value==null||value=="")
    {
    alert(alerttxt);return false;
    }
  else
    {
    return true;
    }
  }
}
function validate_form(thisform)
  {
  with (thisform)
  {
  if (validate_required(email,"Email must be filled out!")==false)
  {email.focus();return false;}
  }
  }
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form action="submit.htm" onsubmit="return validate_form(this)" method="post"&gt;
  Email: &lt;input type="text" name="email" size="30"&gt;
&lt;input type="submit" value="Submit"&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;</code></pre>
<p><strong>E-mail Validation</strong></p>
<p>The function below checks if the content has the general syntax of an email.</p>
<p>This means that the input data must contain at least an @ sign and a dot (.). Also, the @ must not be the first character of the email address, and the last dot must at least be one character after the @ sign:</p>
<pre><code>function validate_email(field,alerttxt)
{
with (field)
  {
  apos=value.indexOf("@");
  dotpos=value.lastIndexOf(".");
  if (apos&lt;1||dotpos-apos&lt;2)
    {alert(alerttxt);return false;}
  else {return true;}
  }
}</code></pre>
<p>The entire script, with the HTML form could look something like this:</p>
<pre><code>

&lt;html&gt;
&lt;head&gt;
&lt;script type="text/javascript"&gt;
function validate_email(field,alerttxt)
{
with (field)
  {
  apos=value.indexOf("@");
  dotpos=value.lastIndexOf(".");
  if (apos&lt;1||dotpos-apos&lt;2)
    {alert(alerttxt);return false;}
  else {return true;}
  }
}

function validate_form(thisform)

  {

  with (thisform)

  {

  if (validate_email(email,"Not a valid e-mail address!")==false)

  {email.focus();return false;}

  }

  }

&lt;/script&gt;

&lt;/head&gt;

&lt;body&gt;

&lt;form action="submit.htm" onsubmit="return validate_form(this);" method="post"&gt;

  Email: &lt;input type="text" name="email" size="30"&gt;

&lt;input type="submit" value="Submit"&gt;

&lt;/form&gt;

&lt;/body&gt;

&lt;/html&gt;&gt;

</code></pre>
<p>Source : <a href="http://www.w3schools.com%20" target="_blank">w3schools</a></p>
<p>Any interactive web site has form input &#8211; a place where the users input different kind of information. This data is passed to ASP script, or some other technology and if the data contains an error, there will be a delay before the information travels over the Internet to the server, is examined on the server, and then returns to the user along with an error message.   If you run a validation of the user’s form input before the form is submitted, there will be no wait time and redundant load on the server. &#8220;Bad data&#8221; are already filtered out when input is passed to the server-based program. It also allows to simplify server-based program.   Client side form validation usually done with javascript. For the majority of your users, JavaScript form validation will save a lot of time up front, but double-checking the data on the server remains necessary, in case the user has turned JavaScript off.   Form data that typically are checked by a JavaScript could be:</p>
<ul>
<li>Required fields</li>
<li> Valid user name</li>
<li> Valid password</li>
<li> Valid e-mail address</li>
<li> Valid phone number</li>
</ul>
<p><strong>validateFormOnSubmit ( )</strong> This is a main function that calls a series of subfunctions, each of which checks a single form element for compliance. If the element complies than sufunction returns an empty string. Otherwise it returns a message describing the error and highlight appropriate element with yellow.</p>
<pre><code>function validateFormOnSubmit(theForm) {
var reason = "";

 reason += validateUsername(theForm.username);

  reason += validatePassword(theForm.pwd);

  reason += validateEmail(theForm.email);

  reason += validatePhone(theForm.phone);

  reason += validateEmpty(theForm.from);

  if (reason != "") {

  alert("Some fields need correction:\n" + reason);

  return false;

  }

 return true;

  }</code></pre>
<p><strong>validateEmpty ( )</strong></p>
<p>The function below checks if a required field has been left empty. If the required field is blank, we return the error string to the main function. If it’s not blank, the function returns an empty string.</p>
<pre><code>function validateEmpty(fld) {
    var error = "";

    if (fld.value.length == 0) {
        fld.style.background = 'Yellow';
        error = "The required field has not been filled in.\n"
    } else {
        fld.style.background = 'White';
    }
    return error;
}</code></pre>
<p><strong>validateUsername ( )</strong></p>
<p>The function below checks if the user entered anything at all in the username field. If it’s not blank, we check the length of the string and permit only usernames that are between 5 and 15 characters. Next, we use the JavaScript regular expression /\W/ to forbid illegal characters from appearing in usernames. We want to allow only letters, numbers and underscopes.</p>
<pre><code>function validateUsername(fld) {
    var error = "";
    var illegalChars = /\W/; // allow letters, numbers, and underscores

    if (fld.value == "") {
        fld.style.background = 'Yellow';
        error = "You didn't enter a username.\n";
    } else if ((fld.value.length &lt; 5) || (fld.value.length &gt; 15)) {
        fld.style.background = 'Yellow';
        error = "The username is the wrong length.\n";
    } else if (illegalChars.test(fld.value)) {
        fld.style.background = 'Yellow';
        error = "The username contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    }
    return error;
}</code></pre>
<p><strong>validatePassword ( )</strong></p>
<p>The function below checks the password field for blankness and allow only letters and numbers &#8211; no underscopes this time. So we should use a new regular expression to forbid underscopes. This one /[\W_]/ allow only letters and numbers. Next, we want to permit only passwords that contain letters and at least one numeral. For that we use the seacrh() method and two more regular expressions: /(a-z)+/ and /(0-9)/.</p>
<pre><code>function validatePassword(fld) {
    var error = "";
    var illegalChars = /[\W_]/; // allow only letters and numbers 

    if (fld.value == "") {
        fld.style.background = 'Yellow';
        error = "You didn't enter a password.\n";
    } else if ((fld.value.length &lt; 7) || (fld.value.length &gt; 15)) {
        error = "The password is the wrong length. \n";
        fld.style.background = 'Yellow';
    } else if (illegalChars.test(fld.value)) {
        error = "The password contains illegal characters.\n";
        fld.style.background = 'Yellow';
    } else if (!((fld.value.search(/(a-z)+/)) &amp;&amp; (fld.value.search(/(0-9)+/)))) {
        error = "The password must contain at least one numeral.\n";
        fld.style.background = 'Yellow';
    } else {
        fld.style.background = 'White';
    }
   return error;
}  </code></pre>
<p><strong>validateEmail ( )</strong></p>
<p>Next we want to see if the email address the user entered is real. This means that the input data must contain at least an @ sign and a dot (.). Also, the @ must not be the first character of the email address, and the last dot must at least be one character after the @ sign.</p>
<p>At first we check if the user entered anything at all in the email field. Next, we use regular expression and the test() method to check the field for a compliance. Also we will use trim() function that will trim leading whitespace off the string. This won’t be perfect validation — it is possible to slip not compliant addresses by it — but it&#8217;s normally good enough.</p>
<pre><code>function trim(s)
{
  return s.replace(/^\s+|\s+$/, '');
}
function validateEmail(fld) {

  var error="";

  var tfld = trim(fld.value); // value of field with whitespace trimmed off

  var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;

  var illegalChars= /[\(\)\&lt;\&gt;\,\;\:\\\"\[\]]/ ;

  if (fld.value == "") {

  fld.style.background = 'Yellow';

  error = "You didn't enter an email address.\n";

  } else if (!emailFilter.test(tfld)) { //test email for illegal characters

  fld.style.background = 'Yellow';

  error = "Please enter a valid email address.\n";

  } else if (fld.value.match(illegalChars)) {

  fld.style.background = 'Yellow';

  error = "The email address contains illegal characters.\n";

  } else {

  fld.style.background = 'White';

  }

  return error;

  }</code></pre>
<p><strong>validatePhone ( )</strong></p>
<p>The function below checks if the phone number is valid. At first we use regular expression and the replace() method to clear out any spacer characters. Next, we use the isNaN() function to check if the phone number contain only numbers. At last we check the length of the string and permit only phone numbers with 10 digits.</p>
<pre><code>function validatePhone(fld) {
    var error = "";
    var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, ''); 

 if (fld.value == "") {

  error = "You didn't enter a phone number.\n";

  fld.style.background = 'Yellow';

  } else if (isNaN(parseInt(stripped))) {

  error = "The phone number contains illegal characters.\n";

  fld.style.background = 'Yellow';

  } else if (!(stripped.length == 10)) {

  error = "The phone number is the wrong length. Make sure you included an area code.\n";

  fld.style.background = 'Yellow';

  } 

  return error;

  }    </code></pre>
<p><strong>check Dropdown()</strong></p>
<p>Finally, we want to make sure that the user has selected an option from our drop-down menu (and not the first option, which isn’t an option at all, but just a &#8220;Choose one&#8221; header). For this, we use the select object’s selectedIndex property, which returns the index of the selected option. If the index is 0, we reject the input.</p>
<pre><code>function checkDropdown(choice) {
    var error = "";
    if (choice == 0) {
       error = "You didn't choose an option
         from the drop-down list.\n";
    }
return error;
}    </code></pre>
<p><strong>checkRadio()</strong></p>
<p>To make sure that a radio button has been chosen from a selection, we run through the array of radio buttons and count the number that have been checked. Rather than sending the whole radio object to a subfunction, which can be problematic (because the radio object has no property indicating which value has been chosen), we pre-process the radio form element in a for loop and send that result to a subfunction for evaluation.</p>
<pre><code>for (i=0, n=theForm.radios.length; i&lt;n; i++) {
   if (theForm.radios[i].checked) {
      var checkvalue = theForm.radios[i].value;
      break;
   }
}
why += checkRadio(checkvalue);

function checkRadio(checkvalue) {
var error = "";
   if (!(checkvalue)) {
       error = "Please check a radio button.\n";
    }
return error;
}</code></pre>
<p><strong>isDifferent()</strong></p>
<p>We want to do a few more kinds of validation. If you present a license or something similar in a text box for the user to accept, you want to make sure that it hasn’t been altered when the form is submitted. That’s done very simply by comparing the submitted string with the string you were expecting.</p>
<pre><code>function isDifferent(strng) {
  var error = "";
  if (strng != "Can\'t touch this!") {
     error = "You altered the inviolate text area.\n";
  }</code></pre>
<p>Alternately, you can use the onChange() method to catch the user in the act of modifying the text and stop them before they submit the form.</p>
<p><strong>HTML Form</strong></p>
<p>This script accompanies an HTML form. When the user clicks the Submit button on the form, the form data is sent to a JavaScript validation function that checks each field to make sure that it is in the appropriate format. The HTML form could look something like this:</p>
<pre><code>&lt;html&gt;
&lt;head&gt;
&lt;title&gt;WebCheatSheet - JavaScript Tutorial&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;WebCheatSheet - JavaScript Tutorial&lt;/h1&gt;

&lt;form name="demo" onsubmit="return validateFormOnSubmit(this)" action="test.htm"&gt;

&lt;table summary="Demonstration form"&gt;

&lt;tbody&gt;

&lt;tr&gt;

&lt;td&gt;&lt;label for="username"&gt;Your user name:&lt;/label&gt;&lt;/td&gt;

&lt;td&gt;&lt;input name="username" size="35" maxlength="50" type="text"&gt;&lt;/td&gt;

&lt;/tr&gt; 

&lt;tr&gt;

&lt;td&gt;&lt;label for="pwd"&gt;Your password&lt;/label&gt;&lt;/td&gt;

&lt;td&gt;&lt;input name="pwd" size="35" maxlength="25" type="password"&gt;&lt;/td&gt;

&lt;/tr&gt; 

&lt;tr&gt;

&lt;td&gt;&lt;label for="email"&gt;Your email:&lt;/label&gt;&lt;/td&gt;

&lt;td&gt;&lt;input name="email" size="35" maxlength="30" type="text"&gt;&lt;/td&gt;

&lt;/tr&gt; 

&lt;tr&gt;

&lt;td&gt;&lt;label for="phone"&gt;Your telephone number:&lt;/label&gt;&lt;/td&gt;

&lt;td&gt;&lt;input name="phone" size="35" maxlength="25" type="text"&gt;&lt;/td&gt;

&lt;/tr&gt; 

&lt;tr&gt;

&lt;td&gt;

&lt;label for="from"&gt;Where are you :&lt;/label&gt;&lt;/td&gt;

&lt;td&gt;&lt;input name="from" size="35" maxlength="50" type="text"&gt;&lt;/td&gt;

&lt;/tr&gt; 

&lt;tr&gt;

&lt;td&gt;&amp;nbsp;&lt;/td&gt;

&lt;td&gt;&lt;input name="Submit" value="Send" type="submit" &gt;&lt;/td&gt;

&lt;td&gt;&amp;nbsp;&lt;/td&gt;

&lt;/tr&gt; 

&lt;/tbody&gt;

&lt;/table&gt;

&lt;/form&gt; 

&lt;/body&gt;

&lt;/html&gt;</code></pre>
<h3>Javascript form validation – doing it right</h3>
<p>When using Javascript for form validation, there is a right way, a wrong way, a very wrong way, and a suicidally wrong way! Unfortunately many sites use one of the wrong ways, including even some which claim to be form-validation tutorials. This page tries to help people in the right direction.</p>
<ul>
<li>The suicidally wrong way is to have the validation in Javascript only, and not on the server. A malicious user can easily bypass it and – depending on what you are doing – may wreak havoc with your database. Apparently there have been cases of online shops shipping computers for $1 because they had no server-side validation!</li>
<li> The very wrong (but all too common) way is to simply assume the user has Javascript. Readers who have disabled it (and there are several good reasons for doing so) or who do not have it available, spend their time filling in the form and then find nothing happens when they click the submit button.</li>
<li>The wrong way is to give the non-Javascript user, or the user of a browser other than IE or Netscape, a terse message telling him he can&#8217;t use your site.</li>
<li>The right way (got there eventually!) is to use Javascript as an optional extra to improve user-friendliness. All form submissions are validated on the server. If the reader has Javascript available, an initial validation is done on the client, to check for simple errors such as missing information or non-numeric characters in a numeric field. This means the reader gets faster feedback than waiting for a response from the server.</li>
</ul>
<p>The essence is thus that Javascript validation is always optional. Since the validation must be on the server anyway, it is silly to insist that the user must have Javascript. Adding Javascript validation should help some readers and hinder nobody.</p>
<p><strong>How it works</strong></p>
<p>I&#8217;m not going to describe all the workings in detail, as they are commented in reasonable detail in the code. If you aren&#8217;t familiar with the basics of Javascript and forms, there are plenty of sites on the Web which can help. Instead I will point out the key features of this approach.</p>
<ol>
<li>It uses a standard submit button and onsubmit handler; therefore the submission still works if the user has no Javascript available.</li>
<li> Validation is done by onchange handlers, so the user gets immediate feedback on each field. (Not onblur, which can lead to premature validation if e.g. a pop-up fires off, or the user wants to copy data from elsewhere.) The calls to the validation routines are repeated in the onsubmit handler, in case the user skipped over some fields.</li>
<li> It makes minimal use of alert boxes: errors are written into the HTML. The user is not driven up the wall by alert boxes for every error, and the error message remains visible until he/she has finished the correction of the field.A single alert pops up if the user clicks &#8216;Send&#8217; while there are still errors. This is necessary to give positive feedback.</li>
<li> The script checks for older browsers and less well-endowed browsers (e.g. Netscape 4, WebTV). This is not to exclude them; on the contrary, it is to ensure that users of these browsers can also use the form – they just have to wait for the validation to be performed by the server.</li>
<li> The detection of these older browsers is done by feature detection, not browser sniffing – this is much more reliable (and simpler as well!). For example, the script checks whether methods such as document.getElementById are defined, rather than checking whether the browser claims to be Mozilla.</li>
<li>The formatting of error and alert messages is done by setting the CSS class of the element concerned. This is both simpler and more maintainable than using FONT tags or setting CSS properties directly.</li>
</ol>
<p>One thing I have not done is put up a positive OK indication by fields when they pass validation. My feeling is that this could be misleading, as one only really knows the field is OK after the server validation is complete. But in some circumstances it might be a good idea.</p>
<p>One other thing I have not done, which is rarely if ever a good idea, is to force the user to complete fields in a particular order, or to prevent him/her from leaving a field until it is correct. I do use the focus function to assist the user, but he/she is free to move to a different field if desired.</p>
<p><strong>Auto-completion problem</strong></p>
<p>There is one small problem that a couple of correspondents have pointed out to me. There is a bug in Internet Explorer (all versions, as far as I know) whereby the onChange event does not fire if the user makes use of auto-completion. There doesn&#8217;t seem to be a good way around this. (I have found a couple of sites referring to the non-standard onPropertyChange event, but this fires on every keystroke, so is not of any use.)</p>
<p>The only option seems to be, if in a particular case this is likely to be seriously confusing to the user, to switch auto-completion off with the non-standard autocomplete attribute on the form. Or perhaps one could use IE Conditional Comments to at least give IE users a warning message.</p>
<p><strong>How much validation? </strong></p>
<p>Exactly how detailed client-side validation should be is a debatable point. There is little point in trying to make it really rigorous, since some aspects can typically only be validated on the server anyway. And since the aim is quick response to the user, it rather defeats the object to load the form down with many kilobytes of Javascript. On the other hand, if one is for example validating an e-mail address, I think one can do rather better than simply checking that an &#8216;@&#8217; is present somewhere in the string, as I have seen a couple of times.</p>
<p>On only one point do I have strong feelings: input should never be rejected due to the presence of leading or trailing white-space. It may be difficult for the user to see that the white-space is present, and failing to strip it off before validation is pure laziness on the part of the programmer. (This includes line-breaks, which may inadvertently be included if the user copies text from elsewhere; using ‘\s’ within a regular expression will look after this.)</p>
<p>There is of course much more to be said about validation in general. Witness the site designers who insist that credit-card start-date is a compulsory field, although some credit cards (including mine) do not have a start date. But this page concentrates specifically on the client-side aspects, so I&#8217;ll leave the rest for another time.</p>
<p>Source: <a href="http://www.xs4all.nl/%7Esbpoley/webmatters/formval.html" target="_blank">View here</a><br />
<h3>See Also Following Topics:</h3>
<ul class="related_post">
<li><a href="http://www.themeheven.com/2009/08/javascript-built-in-object-method-properties-handling-events-in-browser/" title="JavaScript Built in Object, Method, Properties &#038; Handling Events in browser">JavaScript Built in Object, Method, Properties &#038; Handling Events in browser</a></li>
<li><a href="http://www.themeheven.com/2009/04/javascript-effect/" title="Javascript Effect">Javascript Effect</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.themeheven.com/2009/05/various-method-javascript-form-validation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript Effect</title>
		<link>http://www.themeheven.com/2009/04/javascript-effect/</link>
		<comments>http://www.themeheven.com/2009/04/javascript-effect/#comments</comments>
		<pubDate>Wed, 29 Apr 2009 08:18:19 +0000</pubDate>
		<dc:creator>themeheven</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.themeheven.com/?p=149</guid>
		<description><![CDATA[ Fader-Image Effects
This script demonstrates various techniques for fading the background of your selected HTML components such as buttons, text boxes, page backgrounds, and others to different color.
Installing Fader effect in your page
 1. Copy the coding into the HEAD of your HTML document
 2. Add the id property into the BODY tag
 3. Put [...]]]></description>
			<content:encoded><![CDATA[<h2> Fader-Image Effects</h2>
<p>This script demonstrates various techniques for fading the background of your selected HTML components such as buttons, text boxes, page backgrounds, and others to different color.</p>
<p><strong>Installing Fader effect in your page</strong></p>
<p> 1. Copy the coding into the HEAD of your HTML document</p>
<p> 2. Add the id property into the BODY tag</p>
<p> 3. Put the last coding into the BODY of your HTML document </p>
<p><strong>Paste this code into the HEAD of your HTML document</strong></p>
<p><pre><code>&lt;HEAD&gt;&lt;script type=&quot;text/javascript&quot;&gt;&lt;!-- Begin  /* This script and many more are available free online at  The JavaScript Source!! http://javascript.internet.com  Created by: Tony Tschopp :: http://www.goodturnwebdesign.com *//* comp = name (ID=&quot;comp&quot;) of the HTML page component to fade  cbeg = start value for color in #rrggbb format  cend = end value for color in #rrggbb format  iter = number of steps in the fade from start color to end color  time = number of milliseconds to display each step  rbeg = start value for red component of rbg color  gbeg = start value for green component of rbg color  bbeg = start value for blue component of rbg color  rend = end value for red component of rbg color  gend = end value for green component of rbg color  bend = end value for blue component of rbg color */var hstr = '#';  var hdig = &quot;0123456789abcdef&quot;;  function mOvr(comp, cbeg, cend, iter, time) {  var rbeg = hdig.indexOf(cbeg.substr(1,1))*16 + hdig.indexOf(cbeg.substr(2,1));  var gbeg = hdig.indexOf(cbeg.substr(3,1))*16 + hdig.indexOf(cbeg.substr(4,1));  var bbeg = hdig.indexOf(cbeg.substr(5,1))*16 + hdig.indexOf(cbeg.substr(6,1));  var rend = hdig.indexOf(cend.substr(1,1))*16 + hdig.indexOf(cend.substr(2,1));  var gend = hdig.indexOf(cend.substr(3,1))*16 + hdig.indexOf(cend.substr(4,1));  var bend = hdig.indexOf(cend.substr(5,1))*16 + hdig.indexOf(cend.substr(6,1));  for ( i = 1, r = rbeg, g = gbeg, b = bbeg;  i &lt;= iter;  r = Math.round(rbeg + i * ((rend - rbeg) / (iter-1))),  g = Math.round(gbeg + i * ((gend - gbeg) / (iter-1))),  b = Math.round(bbeg + i * ((bend - bbeg) / (iter-1))), i++ ) {  hstr = '#' + hdig.charAt(Math.floor(r/16)) + hdig.charAt(r%16) +  hdig.charAt(Math.floor(g/16)) + hdig.charAt(g%16) +  hdig.charAt(Math.floor(b/16)) + hdig.charAt(b%16);  setTimeout('var el = document.getElementById(&quot;' + comp + '&quot;); el.style.backgroundColor = &quot;' + hstr + '&quot;;', i * time);  }  }function mOut(comp, cbeg, cend, iter, time) {  var rbeg = hdig.indexOf(cbeg.substr(1,1))*16 + hdig.indexOf(cbeg.substr(2,1));  var gbeg = hdig.indexOf(cbeg.substr(3,1))*16 + hdig.indexOf(cbeg.substr(4,1));  var bbeg = hdig.indexOf(cbeg.substr(5,1))*16 + hdig.indexOf(cbeg.substr(6,1));  var rend = hdig.indexOf(cend.substr(1,1))*16 + hdig.indexOf(cend.substr(2,1));  var gend = hdig.indexOf(cend.substr(3,1))*16 + hdig.indexOf(cend.substr(4,1));  var bend = hdig.indexOf(cend.substr(5,1))*16 + hdig.indexOf(cend.substr(6,1));  for ( i = 1, r = rend, g = gend, b = bend;  i &lt;= iter;  r = Math.round(rend - i * ((rend - rbeg) / (iter-1))), g = Math.round(gend - i * ((gend - gbeg) / (iter-1))),  b = Math.round(bend - i * ((bend - bbeg) / (iter-1))), i++ ) {  hstr = '#' + hdig.charAt(Math.floor(r/16)) + hdig.charAt(r%16) +  hdig.charAt(Math.floor(g/16)) + hdig.charAt(g%16) +  hdig.charAt(Math.floor(b/16)) + hdig.charAt(b%16);  setTimeout('var el = document.getElementById(&quot;' + comp + '&quot;); el.style.backgroundColor = &quot;' + hstr + '&quot;;', i * time);  }  }  // End --&gt;&lt;/script&gt;&lt;/HEAD&gt;</code></pre>
</p>
<h2>Daily Welcome Cookie</h2>
<p>This script sets a cookie, with an alert window that only comes up the first time you visit the page each day. Good for calling attention to daily specials and news updates. Can be configured to work in other ways also.</p>
<p>Paste this code into the HEAD section of your HTML document</p>
<p>
<pre><code>&lt;script type=&quot;text/javascript&quot; src=&quot;dailyCookie.js&quot;&gt;&lt;/script&gt;</code></pre>
</p>
<p>Paste this code into an external JavaScript file named: dailyCookie.js</p>
<p>
<pre><code>

/* This script and many more are available free online at
  The JavaScript Source!! http://javascript.internet.com
  Created by: Ted Man |  */

  function getCookie(c_name) {
  if (document.cookie.length&gt;0) {
  c_start=document.cookie.indexOf(c_name + &quot;=&quot;)
  if (c_start!=-1) {
c_start=c_start + c_name.length+1 
c_end=document.cookie.indexOf(&quot;;&quot;,c_start)
  if (c_end==-1) c_end=document.cookie.length
  return unescape(document.cookie.substring(c_start,c_end))
  } 
  }
  return &quot;&quot;
  }

  function setCookie(c_name,value,expiredays) {
  var exdate=new Date()
  exdate.setDate(exdate.getDate()+expiredays)
  document.cookie=c_name+ &quot;=&quot; + escape(value) + ((expiredays==null) ? &quot;&quot; : &quot;; expires=&quot;+exdate.toGMTString())
  }

  function checkCookie() {
  var todaysdate = new Date()
  var day = todaysdate.getDay()
  switch (day) {
  case 1:
  day = &quot;Monday&quot;
  break
  case 2:
  day = &quot;Tuesday&quot;
  break
  case 3:
  day = &quot;Wednesday&quot;
  break
  case 4:
  day = &quot;Thursday&quot;
  break
  case 5:
  day = &quot;Friday&quot;
  break
  case 6:
  day = &quot;Saturday&quot;
  break
  case 0:
  day = &quot;Sunday&quot;
  break
  }

  var thedate = getCookie('thedate')
  if (thedate != null &amp;&amp; thedate != &quot;&quot;) {
  if (day == thedate) {
  } else {
  alert('Be sure to check our daily specials!')
  }
  } else {
thedate = day 
if (thedate!=null &amp;&amp; thedate!=&quot;&quot;) {
  setCookie('thedate', thedate, 365)
  alert('Be sure to check our daily specials!')
  }
  }
  }
  // Multiple onload function created by: Simon Willison
  // http://simonwillison.net/2004/May/26/addLoadEvent/
  function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
  window.onload = func;
  } else {
  window.onload = function() {
  if (oldonload) {
  oldonload();
  }
  func();
  }
  }
  }
  addLoadEvent(function() {
  checkCookie();
  });</code></pre>
</p>
<h2>Copy from Forms to Clipboard</h2>
<p>There are many scripts for copying text from a Web page that work fine in MS Internet Explorer but not in Firefox, Netscape, or Opera. This cross-browser script, however, will do the trick. It will copy a designated portion of text into the Windows clipboard, using a small Macromedia Flash file to perform the copy on the browser&#8217;s behalf.</p>
<p>Paste this code into an external JavaScript file named: clipboardCopy.js</p>
<p>
<pre><code>/* This script and many more are available free online atThe JavaScript Source!! http://javascript.internet.comCreated by: Mark O'Sullivan :: http://lussumo.com/ Jeff Larson :: http://www.jeffothy.com/ Mark Percival :: http://webchicanery.com/function copy(text2copy) {  if (window.clipboardData) {    window.clipboardData.setData(&quot;Text&quot;,text2copy);  } else {    var flashcopier = 'flashcopier';    if(!document.getElementById(flashcopier)) {      var divholder = document.createElement('div');      divholder.id = flashcopier;      document.body.appendChild(divholder);    }    document.getElementById(flashcopier).innerHTML = '';    var divinfo = '&lt;embed src=&quot;_clipboard.swf&quot; FlashVars=&quot;clipboard='+escape(text2copy)+'&quot; width=&quot;0&quot; height=&quot;0&quot; type=&quot;application/x-shockwave-flash&quot;&gt;&lt;/embed&gt;';    document.getElementById(flashcopier).innerHTML = divinfo;  }}</code></pre>
</p>
<p>Paste this code into the HEAD section of your HTML document.</p>
<p>
<pre><code>&lt;script type=&quot;text/javascript&quot; src=&quot;clipboardCopy.js&quot;&gt;&lt;/script&gt;</code></pre>
</p>
<p>Paste this code into the BODY section of your HTML document</p>
<p>
<pre><code>
  &lt;form name=&quot;form1&quot; action=&quot;&quot;&gt;
&lt;textarea name=&quot;results&quot; cols=&quot;40&quot; rows=&quot;6&quot;&gt;All of the text here will be copied. Epsum factorial non deposit quid pro quo hic escorol. Olypian quarrels et gorilla congolium sic ad nauseum. Souvlaki ignitus carborundum.&lt;/textarea&gt;
&lt;br&gt;
&lt;input type=&quot;button&quot; value=&quot;Copy This&quot; onclick=&quot;copy(document.form1.results.value);&quot;&gt;
&lt;/form&gt;</code></pre>
</p>
<h3>See Also Following Topics:</h3>
<ul class="related_post">
<li><a href="http://www.themeheven.com/2009/08/javascript-built-in-object-method-properties-handling-events-in-browser/" title="JavaScript Built in Object, Method, Properties &#038; Handling Events in browser">JavaScript Built in Object, Method, Properties &#038; Handling Events in browser</a></li>
<li><a href="http://www.themeheven.com/2009/05/various-method-javascript-form-validation/" title="Various Method JavaScript Form Validation">Various Method JavaScript Form Validation</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.themeheven.com/2009/04/javascript-effect/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- www.000webhost.com Analytics Code -->
<script type="text/javascript" src="http://analytics.hosting24.com/count.php"></script>
<noscript><a href="http://www.hosting24.com/"><img src="http://analytics.hosting24.com/count.php" alt="web hosting" /></a></noscript>
<!-- End Of Analytics Code -->
