<?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>PHP Magic Book - Free PHP Scripts, Tutorials and Downloads &#187; Form Validation</title>
	<atom:link href="http://www.phpmagicbook.com/tag/form-validation/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.phpmagicbook.com</link>
	<description>PHP AtoZ Reloaded, free php tutorials, free php downloads, php scripts, PHP tips</description>
	<lastBuildDate>Tue, 15 Jun 2010 13:22:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Captcha &#8211; Random Image Form Validation Using PHP</title>
		<link>http://www.phpmagicbook.com/captcha-random-image-form-validation/</link>
		<comments>http://www.phpmagicbook.com/captcha-random-image-form-validation/#comments</comments>
		<pubDate>Wed, 18 Jun 2008 23:48:33 +0000</pubDate>
		<dc:creator>Hiroshi</dc:creator>
				<category><![CDATA[Captcha]]></category>
		<category><![CDATA[Form Validation]]></category>
		<category><![CDATA[Rand]]></category>
		<category><![CDATA[Randomizing]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Spam Control]]></category>

		<guid isPermaLink="false">http://www.phpmagicbook.com/?p=127</guid>
		<description><![CDATA[Similar to Number &#038; Image form validation this example takes images with digits randomly and displays these for validating form. Random Image Form Validation PHP Script Download Captcha &#8211; Random Image Form Validation Using PHP is a post from: PHP Magic Book - Free PHP Scripts, Tutorials and Downloads Related PostsCaptcha &#8211; Image And Number [...]<p><a href="http://www.phpmagicbook.com/captcha-random-image-form-validation/">Captcha &#8211; Random Image Form Validation Using PHP</a> is a post from: <a href="http://www.phpmagicbook.com">PHP Magic Book - Free PHP Scripts, Tutorials and Downloads</a></p>
]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.phpmagicbook.com/wp-content/uploads/2008/06/captcha-form-validation.jpg" alt="Form validation using random images" title="Captcha Form Validation" width="219" height="89" class="aligncenter size-full wp-image-128" /></p>
<p>Similar to <a href="http://www.phpmagicbook.com/captcha-image-number-verification/">Number &#038; Image form validation</a> this example takes images with digits randomly and displays these for validating form.</p>
<p><span id="more-204"></span></p>
<p><a href='http://www.phpmagicbook.com/wp-content/uploads/2008/06/random-image-form-validation.rar' class="download">Random Image Form Validation PHP Script Download</a></p>
<p><a href="http://www.phpmagicbook.com/captcha-random-image-form-validation/">Captcha &#8211; Random Image Form Validation Using PHP</a> is a post from: <a href="http://www.phpmagicbook.com">PHP Magic Book - Free PHP Scripts, Tutorials and Downloads</a></p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.phpmagicbook.com/captcha-image-number-verification/" title="Captcha &#8211; Image And Number Verification Using PHP">Captcha &#8211; Image And Number Verification Using PHP</a></li><li><a href="http://www.phpmagicbook.com/htaccess-essential-tricks-for-blog-website-performance-a-guide/" title=".htaccess Essential Tricks For Blog/Website Performance &#8211; Guide">.htaccess Essential Tricks For Blog/Website Performance &#8211; Guide</a></li><li><a href="http://www.phpmagicbook.com/php-is-not-secure/" title="PHP is Not Secure">PHP is Not Secure</a></li><li><a href="http://www.phpmagicbook.com/protect-php-dot-ini-file-from-being-viewed/" title="Protect php dot ini file from being viewed">Protect php dot ini file from being viewed</a></li><li><a href="http://www.phpmagicbook.com/php-essential-security-fixes-for-your-website/" title="PHP Essential Security Fixes For Your Website">PHP Essential Security Fixes For Your Website</a></li><li><a href="http://www.phpmagicbook.com/text-to-image-using-php/" title="Text To Image Using PHP">Text To Image Using PHP</a></li><li><a href="http://www.phpmagicbook.com/browser-check-with-php/" title="Browser Check With PHP">Browser Check With PHP</a></li><li><a href="http://www.phpmagicbook.com/random-number-verification-simple-form-authentication/" title="Random Number Verification &#8211; Simple Form Authentication Using PHP">Random Number Verification &#8211; Simple Form Authentication Using PHP</a></li><li><a href="http://www.phpmagicbook.com/advanced-form-validation-by-message-no-alert-dialogue-box/" title="Advanced Form Validation and Displaying Error Message &#8211; No Alert Dialogue Box">Advanced Form Validation and Displaying Error Message &#8211; No Alert Dialogue Box</a></li><li><a href="http://www.phpmagicbook.com/phone-number-actual-validation/" title="Phone Number Actual Validation">Phone Number Actual Validation</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.phpmagicbook.com/captcha-random-image-form-validation/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Captcha &#8211; Image And Number Verification Using PHP</title>
		<link>http://www.phpmagicbook.com/captcha-image-number-verification/</link>
		<comments>http://www.phpmagicbook.com/captcha-image-number-verification/#comments</comments>
		<pubDate>Wed, 18 Jun 2008 23:35:44 +0000</pubDate>
		<dc:creator>Hiroshi</dc:creator>
				<category><![CDATA[Captcha]]></category>
		<category><![CDATA[Form Validation]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Spam Control]]></category>
		<category><![CDATA[image]]></category>

		<guid isPermaLink="false">http://www.phpmagicbook.com/?p=124</guid>
		<description><![CDATA[This example is simple php, javascript image and number form validation. You can show number or image or both. If users enters correct number displayed then he can proceed with form submission. This example is using images containing numbers and these display randomly to validate form. Random Number Images Form Validation Captcha Example Download Captcha [...]<p><a href="http://www.phpmagicbook.com/captcha-image-number-verification/">Captcha &#8211; Image And Number Verification Using PHP</a> is a post from: <a href="http://www.phpmagicbook.com">PHP Magic Book - Free PHP Scripts, Tutorials and Downloads</a></p>
]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.phpmagicbook.com/wp-content/uploads/2008/06/captcha-1-1.jpg" alt="captcha, form authentication, form validation by image using php and javascript" title="Captcha Image And Number Verification" width="221" height="275" class="aligncenter size-full wp-image-125" /></p>
<p>This example is simple php, javascript image and number form validation. You can show number or image or both. If users enters correct number displayed then he can proceed with form submission. This example is using images containing numbers and these display randomly to validate form.</p>
<p><span id="more-203"></span></p>
<p><a href='http://www.phpmagicbook.com/wp-content/uploads/2008/06/random-number-images-verification-captcha.rar' class="download">Random Number Images Form Validation Captcha Example Download</a></p>
<p><a href="http://www.phpmagicbook.com/captcha-image-number-verification/">Captcha &#8211; Image And Number Verification Using PHP</a> is a post from: <a href="http://www.phpmagicbook.com">PHP Magic Book - Free PHP Scripts, Tutorials and Downloads</a></p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.phpmagicbook.com/captcha-random-image-form-validation/" title="Captcha &#8211; Random Image Form Validation Using PHP">Captcha &#8211; Random Image Form Validation Using PHP</a></li><li><a href="http://www.phpmagicbook.com/enable-gravataravatar-at-your-website-gravatar-image-php-script/" title="Enable Gravatar/Avatar at Your Website &#8211; Gravatar Image PHP Script">Enable Gravatar/Avatar at Your Website &#8211; Gravatar Image PHP Script</a></li><li><a href="http://www.phpmagicbook.com/text-to-image-using-php/" title="Text To Image Using PHP">Text To Image Using PHP</a></li><li><a href="http://www.phpmagicbook.com/random-number-verification-simple-form-authentication/" title="Random Number Verification &#8211; Simple Form Authentication Using PHP">Random Number Verification &#8211; Simple Form Authentication Using PHP</a></li><li><a href="http://www.phpmagicbook.com/random-single-image-onload/" title="Random Single Image Onload Using PHP">Random Single Image Onload Using PHP</a></li><li><a href="http://www.phpmagicbook.com/php-javascript-based-image-gallery/" title="PHP Javascript Based Auto Populated Image Gallery">PHP Javascript Based Auto Populated Image Gallery</a></li><li><a href="http://www.phpmagicbook.com/display-images-from-folder/" title="Auto Display Images From Folder Using PHP">Auto Display Images From Folder Using PHP</a></li><li><a href="http://www.phpmagicbook.com/random-single-image-display-on-page-reload/" title="Random Single Image Display On Page Reload Using PHP">Random Single Image Display On Page Reload Using PHP</a></li><li><a href="http://www.phpmagicbook.com/php-photo-slide-show/" title="Auto Create PHP Photo Slide Show Using PHP">Auto Create PHP Photo Slide Show Using PHP</a></li><li><a href="http://www.phpmagicbook.com/image-gallery/" title="Auto Create Image Gallery from Folder Using PHP">Auto Create Image Gallery from Folder Using PHP</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.phpmagicbook.com/captcha-image-number-verification/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Random Number Verification &#8211; Simple Form Authentication Using PHP</title>
		<link>http://www.phpmagicbook.com/random-number-verification-simple-form-authentication/</link>
		<comments>http://www.phpmagicbook.com/random-number-verification-simple-form-authentication/#comments</comments>
		<pubDate>Wed, 18 Jun 2008 23:11:53 +0000</pubDate>
		<dc:creator>Hiroshi</dc:creator>
				<category><![CDATA[Form Validation]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Spam Control]]></category>
		<category><![CDATA[authentication]]></category>
		<category><![CDATA[Form]]></category>
		<category><![CDATA[number verification]]></category>

		<guid isPermaLink="false">http://www.phpmagicbook.com/?p=122</guid>
		<description><![CDATA[This is simple form authentication by a random number generated by PHP and authenticated by javascript. It can be used for spam control. ~~~ Head Section Code ~~~ PHP Code &#60;?php $mynumber= rand&#40;673,62389&#41;; echo $mynumber; ?&#62; Javascript Code &#60;script type=&#34;text/javascript&#34;&#62; //defining variable and storinging in script var randomnumber= &#60;?= $mynumber?&#62;; // Validating function CheckData&#40;&#41; &#123; [...]<p><a href="http://www.phpmagicbook.com/random-number-verification-simple-form-authentication/">Random Number Verification &#8211; Simple Form Authentication Using PHP</a> is a post from: <a href="http://www.phpmagicbook.com">PHP Magic Book - Free PHP Scripts, Tutorials and Downloads</a></p>
]]></description>
			<content:encoded><![CDATA[<p>This is simple form authentication by a random number generated by PHP and authenticated by javascript. It can be used for spam control.</p>
<p><span id="more-202"></span></p>
<p><strong>~~~ Head Section Code ~~~</strong></p>
<h4>PHP Code</h4>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$mynumber</span><span style="color: #339933;">=</span> <span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">673</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">62389</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$mynumber</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<h4>Javascript Code</h4>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #006600; font-style: italic;">//defining variable and storinging in script</span>
<span style="color: #003366; font-weight: bold;">var</span> randomnumber<span style="color: #339933;">=</span> <span style="color: #339933;">&lt;?=</span> $mynumber<span style="color: #339933;">?&gt;;</span>
<span style="color: #006600; font-style: italic;">// Validating</span>
<span style="color: #003366; font-weight: bold;">function</span> CheckData<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000066; font-weight: bold;">with</span><span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">mail</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>q.<span style="color: #660066;">value</span> <span style="color: #339933;">!=</span> randomnumber<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Please Enter Correct Number&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
q.<span style="color: #000066;">focus</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p><strong>~~~ Body Section Code ~~~</strong></p>
<h4>Form Code</h4>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;form name=&quot;mail&quot; action=&quot;go.php&quot; method=&quot;post&quot; onsubmit=&quot;return CheckData()&quot;&gt;
&lt;input type=&quot;text&quot; name=&quot;q&quot;&gt;
&lt;input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Submit&quot;&gt;
&lt;/form&gt;</pre></div></div>

<p><a href='http://www.phpmagicbook.com/wp-content/uploads/2008/06/random-number-verification.rar' class="download">Random Number Verification PHP Script Download</a></p>
<p><a href="http://www.phpmagicbook.com/random-number-verification-simple-form-authentication/">Random Number Verification &#8211; Simple Form Authentication Using PHP</a> is a post from: <a href="http://www.phpmagicbook.com">PHP Magic Book - Free PHP Scripts, Tutorials and Downloads</a></p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.phpmagicbook.com/advanced-form-validation-by-message-no-alert-dialogue-box/" title="Advanced Form Validation and Displaying Error Message &#8211; No Alert Dialogue Box">Advanced Form Validation and Displaying Error Message &#8211; No Alert Dialogue Box</a></li><li><a href="http://www.phpmagicbook.com/phone-number-actual-validation/" title="Phone Number Actual Validation">Phone Number Actual Validation</a></li><li><a href="http://www.phpmagicbook.com/input-output/" title="Input Output in PHP">Input Output in PHP</a></li><li><a href="http://www.phpmagicbook.com/captcha-random-image-form-validation/" title="Captcha &#8211; Random Image Form Validation Using PHP">Captcha &#8211; Random Image Form Validation Using PHP</a></li><li><a href="http://www.phpmagicbook.com/captcha-image-number-verification/" title="Captcha &#8211; Image And Number Verification Using PHP">Captcha &#8211; Image And Number Verification Using PHP</a></li><li><a href="http://www.phpmagicbook.com/php-user-authentication-without-database/" title="PHP User Authentication Without Database">PHP User Authentication Without Database</a></li><li><a href="http://www.phpmagicbook.com/phone-number-email-validation/" title="Phone Number And Email Validation Update">Phone Number And Email Validation Update</a></li><li><a href="http://www.phpmagicbook.com/number-validation/" title="Number Validation in Forms">Number Validation in Forms</a></li><li><a href="http://www.phpmagicbook.com/using-external-javascript-files/" title="Using External Javascript Files">Using External Javascript Files</a></li><li><a href="http://www.phpmagicbook.com/country-select-and-time-zone-select/" title="Country Select and Time Zone Select">Country Select and Time Zone Select</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.phpmagicbook.com/random-number-verification-simple-form-authentication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Advanced Form Validation and Displaying Error Message &#8211; No Alert Dialogue Box</title>
		<link>http://www.phpmagicbook.com/advanced-form-validation-by-message-no-alert-dialogue-box/</link>
		<comments>http://www.phpmagicbook.com/advanced-form-validation-by-message-no-alert-dialogue-box/#comments</comments>
		<pubDate>Sat, 14 Jun 2008 23:22:47 +0000</pubDate>
		<dc:creator>Hiroshi</dc:creator>
				<category><![CDATA[Form]]></category>
		<category><![CDATA[Form Validation]]></category>

		<guid isPermaLink="false">http://www.phpmagicbook.com/?p=36</guid>
		<description><![CDATA[I have a feeling that every bit of any twitchy and creepy thing with web page can be done with a nice JS file. Got a form? Does it validate? Does it smack your face with a boring alert box saying! &#8220;Hey! Yo! You did not enter your name? Did you think I was stupid [...]<p><a href="http://www.phpmagicbook.com/advanced-form-validation-by-message-no-alert-dialogue-box/">Advanced Form Validation and Displaying Error Message &#8211; No Alert Dialogue Box</a> is a post from: <a href="http://www.phpmagicbook.com">PHP Magic Book - Free PHP Scripts, Tutorials and Downloads</a></p>
]]></description>
			<content:encoded><![CDATA[<p>I have a feeling that every bit of any twitchy and creepy thing with web page can be done with a nice JS file. Got a form? Does it validate? Does it smack your face with a boring alert box saying! &#8220;<strong>Hey! Yo! You did not enter your name? Did you think I was stupid and did not know even that you were not entering data?</strong>&#8220;;</p>
<p>Hmm! Nice&#8230; Time for a bit of a change buddy. Look carefully down at following images and compare. </p>
<p><img src="http://www.phpmagicbook.com/wp-content/uploads/2008/06/1-val.gif" alt="Old Validation" title="Old Validation" width="197" height="119" class="aligncenter size-full wp-image-37" /></p>
<p><img src="http://www.phpmagicbook.com/wp-content/uploads/2008/06/2-val.gif" alt="Advanced Validation" title="New Validation" width="413" height="119" class="aligncenter size-full wp-image-38" /></p>
<p>If you find 2nd one more creepy then read along. Again you need a smart JavaScript file to do the task for you.</p>
<p><span id="more-162"></span></p>
<h4>Javascript Code</h4>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> isValidEmail<span style="color: #009900;">&#40;</span>str<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span>str.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span>str.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;@&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">function</span> CheckData<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'abc'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">style</span>.<span style="color: #660066;">display</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;block&quot;</span><span style="color: #009900;">&#41;</span>
document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'abc'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">style</span>.<span style="color: #660066;">display</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;none&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">with</span><span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">mailform</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000066;">name</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> trim<span style="color: #009900;">&#40;</span><span style="color: #000066;">name</span>.<span style="color: #660066;">value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
phone.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> trim<span style="color: #009900;">&#40;</span>phone.<span style="color: #660066;">value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000066;">name</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'abc'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">style</span>.<span style="color: #660066;">display</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;block&quot;</span><span style="color: #339933;">;</span>
document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'one'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">innerText</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;Please Enter Your First Name&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">name</span>.<span style="color: #000066;">focus</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">function</span> trim<span style="color: #009900;">&#40;</span>sValue<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>sValue <span style="color: #339933;">==</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
		<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> sValue.<span style="color: #660066;">charAt</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot; &quot;</span><span style="color: #339933;">;</span> i <span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	sValue <span style="color: #339933;">=</span> sValue.<span style="color: #660066;">substring</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">,</span>sValue.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>sValue <span style="color: #339933;">==</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
		<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>sValue.<span style="color: #660066;">length</span><span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> sValue.<span style="color: #660066;">charAt</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot; &quot;</span><span style="color: #339933;">;</span> i <span style="color: #339933;">--</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">return</span> sValue.<span style="color: #660066;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">+</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Use this javascript in head section of web page with starting and ending script tags or call it by external js file. It will remove unwanted spaces from entered text and will surprise you if you do not enter any text.</p>
<p>For external js file create a file named as validate.js and call it in head section of web page like this.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;script type=&quot;text/javascript&quot; src=&quot;validate.js&quot;&gt;&lt;/script&gt;</pre></div></div>

<h4>HTML Code</h4>
<p>And a div you need in the web page containing form, to display the hidden surprise; I mean <strong>Error Message</strong>.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;div id=&quot;abc&quot; style=&quot;display:none; color:#FF0000;&quot;&gt;</pre></div></div>

<p>Thats it. Doesn&#8217;t matter if you did not understand a word of this js mystry.<br />
Just download the file and use it, see it for yourself. Stare down a bit at the code and hopefully you will understand somehow. Well&#8230;I did.</p>
<p><a href='http://www.phpmagicbook.com/wp-content/uploads/2008/06/validate_show_message.rar' class="download">Validate And Show Message Magic Download</a></p>
<p><a href="http://www.phpmagicbook.com/advanced-form-validation-by-message-no-alert-dialogue-box/">Advanced Form Validation and Displaying Error Message &#8211; No Alert Dialogue Box</a> is a post from: <a href="http://www.phpmagicbook.com">PHP Magic Book - Free PHP Scripts, Tutorials and Downloads</a></p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.phpmagicbook.com/random-number-verification-simple-form-authentication/" title="Random Number Verification &#8211; Simple Form Authentication Using PHP">Random Number Verification &#8211; Simple Form Authentication Using PHP</a></li><li><a href="http://www.phpmagicbook.com/phone-number-actual-validation/" title="Phone Number Actual Validation">Phone Number Actual Validation</a></li><li><a href="http://www.phpmagicbook.com/input-output/" title="Input Output in PHP">Input Output in PHP</a></li><li><a href="http://www.phpmagicbook.com/captcha-random-image-form-validation/" title="Captcha &#8211; Random Image Form Validation Using PHP">Captcha &#8211; Random Image Form Validation Using PHP</a></li><li><a href="http://www.phpmagicbook.com/captcha-image-number-verification/" title="Captcha &#8211; Image And Number Verification Using PHP">Captcha &#8211; Image And Number Verification Using PHP</a></li><li><a href="http://www.phpmagicbook.com/phone-number-email-validation/" title="Phone Number And Email Validation Update">Phone Number And Email Validation Update</a></li><li><a href="http://www.phpmagicbook.com/number-validation/" title="Number Validation in Forms">Number Validation in Forms</a></li><li><a href="http://www.phpmagicbook.com/using-external-javascript-files/" title="Using External Javascript Files">Using External Javascript Files</a></li><li><a href="http://www.phpmagicbook.com/country-select-and-time-zone-select/" title="Country Select and Time Zone Select">Country Select and Time Zone Select</a></li><li><a href="http://www.phpmagicbook.com/confirm-form-variables-post-before-script-execution/" title="Confirm Form Variables Post Before Script Execution">Confirm Form Variables Post Before Script Execution</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.phpmagicbook.com/advanced-form-validation-by-message-no-alert-dialogue-box/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Phone Number Actual Validation</title>
		<link>http://www.phpmagicbook.com/phone-number-actual-validation/</link>
		<comments>http://www.phpmagicbook.com/phone-number-actual-validation/#comments</comments>
		<pubDate>Sat, 14 Jun 2008 19:02:47 +0000</pubDate>
		<dc:creator>Hiroshi</dc:creator>
				<category><![CDATA[Form]]></category>
		<category><![CDATA[Form Validation]]></category>
		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">http://www.phpmagicbook.com/?p=31</guid>
		<description><![CDATA[In forms to prevent people from writing jhgkljtb7ibylihyb8lyi in phone TextField use the following script. Head Section Code Use this javascript in head section of your webpage. Or use external javasript file. &#60;script language = &#34;Javascript&#34;&#62; // Declaring required variables var digits = &#34;0123456789&#34;; // non-digit characters which are allowed in phone numbers var phoneNumberDelimiters [...]<p><a href="http://www.phpmagicbook.com/phone-number-actual-validation/">Phone Number Actual Validation</a> is a post from: <a href="http://www.phpmagicbook.com">PHP Magic Book - Free PHP Scripts, Tutorials and Downloads</a></p>
]]></description>
			<content:encoded><![CDATA[<p>In forms to prevent people from writing <strong>jhgkljtb7ibylihyb8lyi</strong> in phone TextField use the following script.</p>
<p><span id="more-159"></span></p>
<h4>Head Section Code</h4>
<p>Use this javascript in head section of your webpage. Or <a href="http://www.phpmagicbook.com/using-external-javascript-files/">use external javasript file</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script language <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;Javascript&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #006600; font-style: italic;">// Declaring required variables</span>
<span style="color: #003366; font-weight: bold;">var</span> digits <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;0123456789&quot;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// non-digit characters which are allowed in phone numbers</span>
<span style="color: #003366; font-weight: bold;">var</span> phoneNumberDelimiters <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;()- &quot;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// characters which are allowed in international phone numbers</span>
<span style="color: #006600; font-style: italic;">// (a leading + is OK)</span>
<span style="color: #003366; font-weight: bold;">var</span> validWorldPhoneChars <span style="color: #339933;">=</span> phoneNumberDelimiters <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;+&quot;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// Minimum no of digits in an international phone no.</span>
<span style="color: #003366; font-weight: bold;">var</span> minDigitsInIPhoneNumber <span style="color: #339933;">=</span> <span style="color: #CC0000;">10</span><span style="color: #339933;">;</span> <span style="color: #003366; font-weight: bold;">function</span> isInteger<span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span> <span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> s.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #006600; font-style: italic;">// Check that current character is number.</span>
<span style="color: #003366; font-weight: bold;">var</span> c <span style="color: #339933;">=</span> s.<span style="color: #660066;">charAt</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>c <span style="color: #339933;">&lt;</span> <span style="color: #3366CC;">&quot;0&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #009900;">&#40;</span>c <span style="color: #339933;">&gt;</span> <span style="color: #3366CC;">&quot;9&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #006600; font-style: italic;">// All characters are numbers.</span>
<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> stripCharsInBag<span style="color: #009900;">&#40;</span>s<span style="color: #339933;">,</span> bag<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span> <span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> returnString <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// Search through string's characters one by one.</span>
<span style="color: #006600; font-style: italic;">// If character is not in bag, append to returnString.</span>
<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> s.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #006600; font-style: italic;">// Check that current character isn't whitespace.</span>
<span style="color: #003366; font-weight: bold;">var</span> c <span style="color: #339933;">=</span> s.<span style="color: #660066;">charAt</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>bag.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span>c<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> returnString <span style="color: #339933;">+=</span> c<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000066; font-weight: bold;">return</span> returnString<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> checkInternationalPhone<span style="color: #009900;">&#40;</span>strPhone<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
s<span style="color: #339933;">=</span>stripCharsInBag<span style="color: #009900;">&#40;</span>strPhone<span style="color: #339933;">,</span>validWorldPhoneChars<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span>isInteger<span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> s.<span style="color: #660066;">length</span> <span style="color: #339933;">&gt;=</span> minDigitsInIPhoneNumber<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> ValidateForm<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #003366; font-weight: bold;">var</span> Phone<span style="color: #339933;">=</span>document.<span style="color: #660066;">frmSample</span>.<span style="color: #660066;">txtPhone</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>Phone.<span style="color: #660066;">value</span><span style="color: #339933;">==</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">||</span><span style="color: #009900;">&#40;</span>Phone.<span style="color: #660066;">value</span><span style="color: #339933;">==</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Please Enter your Phone Number&quot;</span><span style="color: #009900;">&#41;</span>
Phone.<span style="color: #000066;">focus</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>checkInternationalPhone<span style="color: #009900;">&#40;</span>Phone.<span style="color: #660066;">value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Please Enter a Valid Phone Number&quot;</span><span style="color: #009900;">&#41;</span>
Phone.<span style="color: #660066;">value</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;&quot;</span>
Phone.<span style="color: #000066;">focus</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<h4>Form Code</h4>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;form name=&quot;frmSample&quot; method=&quot;post&quot; action=&quot;#&quot; onSubmit=&quot;return ValidateForm()&quot;&gt;
&lt;p&gt;Enter a phone number :
&lt;input type=&quot;text&quot; name=&quot;txtPhone&quot;&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Submit&quot;&gt;
&lt;/p&gt;
&lt;/form&gt;</pre></div></div>

<p><a href='http://www.phpmagicbook.com/wp-content/uploads/2008/06/phone-number-validation.rar' class="download">Download Phone Number Validation Script</a></p>
<p><a href="http://www.phpmagicbook.com/phone-number-actual-validation/">Phone Number Actual Validation</a> is a post from: <a href="http://www.phpmagicbook.com">PHP Magic Book - Free PHP Scripts, Tutorials and Downloads</a></p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.phpmagicbook.com/random-number-verification-simple-form-authentication/" title="Random Number Verification &#8211; Simple Form Authentication Using PHP">Random Number Verification &#8211; Simple Form Authentication Using PHP</a></li><li><a href="http://www.phpmagicbook.com/phone-number-email-validation/" title="Phone Number And Email Validation Update">Phone Number And Email Validation Update</a></li><li><a href="http://www.phpmagicbook.com/advanced-form-validation-by-message-no-alert-dialogue-box/" title="Advanced Form Validation and Displaying Error Message &#8211; No Alert Dialogue Box">Advanced Form Validation and Displaying Error Message &#8211; No Alert Dialogue Box</a></li><li><a href="http://www.phpmagicbook.com/number-validation/" title="Number Validation in Forms">Number Validation in Forms</a></li><li><a href="http://www.phpmagicbook.com/confirm-form-variables-post-before-script-execution/" title="Confirm Form Variables Post Before Script Execution">Confirm Form Variables Post Before Script Execution</a></li><li><a href="http://www.phpmagicbook.com/input-output/" title="Input Output in PHP">Input Output in PHP</a></li><li><a href="http://www.phpmagicbook.com/captcha-random-image-form-validation/" title="Captcha &#8211; Random Image Form Validation Using PHP">Captcha &#8211; Random Image Form Validation Using PHP</a></li><li><a href="http://www.phpmagicbook.com/captcha-image-number-verification/" title="Captcha &#8211; Image And Number Verification Using PHP">Captcha &#8211; Image And Number Verification Using PHP</a></li><li><a href="http://www.phpmagicbook.com/using-external-javascript-files/" title="Using External Javascript Files">Using External Javascript Files</a></li><li><a href="http://www.phpmagicbook.com/country-select-and-time-zone-select/" title="Country Select and Time Zone Select">Country Select and Time Zone Select</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.phpmagicbook.com/phone-number-actual-validation/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
