<?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>Flex Examples &#187; validateAll()</title>
	<atom:link href="http://blog.flexexamples.com/tag/validateall/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flexexamples.com</link>
	<description>Just a bunch of Adobe Flex Examples</description>
	<lastBuildDate>Wed, 26 Jan 2011 18:09:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Displaying the error indicator on a Spark FormItem container in Flex Hero</title>
		<link>http://blog.flexexamples.com/2010/08/30/displaying-the-error-indicator-on-a-spark-formitem-container-in-flex-hero/</link>
		<comments>http://blog.flexexamples.com/2010/08/30/displaying-the-error-indicator-on-a-spark-formitem-container-in-flex-hero/#comments</comments>
		<pubDate>Tue, 31 Aug 2010 06:42:54 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Form (Spark)]]></category>
		<category><![CDATA[FormItem (Spark)]]></category>
		<category><![CDATA[Validator]]></category>
		<category><![CDATA[Validators]]></category>
		<category><![CDATA[errorString]]></category>
		<category><![CDATA[Hero]]></category>
		<category><![CDATA[validateAll()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/?p=3323</guid>
		<description><![CDATA[<p>The following example shows how you can display the error indicator on a Spark FormItem container in Flex Hero by setting the errorString property or using the Flex validators.</p> <p></p> &#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62; &#60;!-- http://blog.flexexamples.com/2010/08/30/displaying-the-error-indicator-on-a-spark-formitem-container-in-flex-hero/ --&#62; &#60;s:Application name=&#34;Spark_Form_Validator_test&#34; xmlns:fx=&#34;http://ns.adobe.com/mxml/2009&#34; xmlns:s=&#34;library://ns.adobe.com/flex/spark&#34; xmlns:mx=&#34;library://ns.adobe.com/flex/mx&#34;&#62; &#60;s:layout&#62; &#60;s:VerticalLayout horizontalAlign=&#34;center&#34; verticalAlign=&#34;middle&#34; /&#62; &#60;/s:layout&#62; &#160; &#60;fx:Script&#62; &#60;!&#91;CDATA&#91; import mx.validators.Validator; &#160; protected function [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can display the error indicator on a Spark FormItem container in Flex Hero by setting the <code>errorString</code> property or using the Flex validators.</p>
<p><span id="more-3323"></span></p>
<p class="alert">The following example(s) require Flash Player 10 and the beta Adobe Flex Hero SDK. To download the Adobe Flash Builder 4 trial, see <a href="http://bit.ly/crThlI">http://www.adobe.com/products/flex/</a>. To download the latest nightly build of the Flex Hero SDK, see <a href="http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+Hero">http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+Hero</a>.</strong></p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- http://blog.flexexamples.com/2010/08/30/displaying-the-error-indicator-on-a-spark-formitem-container-in-flex-hero/ --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Application</span> name=<span style="color: #ff0000;">&quot;Spark_Form_Validator_test&quot;</span></span>
<span style="color: #000000;">        xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span></span>
<span style="color: #000000;">        xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span></span>
<span style="color: #000000;">        xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/mx&quot;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:layout</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:VerticalLayout</span> horizontalAlign=<span style="color: #ff0000;">&quot;center&quot;</span> verticalAlign=<span style="color: #ff0000;">&quot;middle&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:layout</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;">&lt;!<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span></span>
<span style="color: #000000;">            import mx.validators.Validator;</span>
&nbsp;
<span style="color: #000000;">            protected function resetBtn_clickHandler<span style="color: #66cc66;">&#40;</span>evt:MouseEvent<span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                username.text = <span style="color: #ff0000;">&quot;&quot;</span>;</span>
<span style="color: #000000;">                password1.text = <span style="color: #ff0000;">&quot;&quot;</span>;</span>
<span style="color: #000000;">                password2.text = <span style="color: #ff0000;">&quot;&quot;</span>;</span>
<span style="color: #000000;">                username.errorString = <span style="color: #ff0000;">&quot;&quot;</span>;</span>
<span style="color: #000000;">                password1.errorString = <span style="color: #ff0000;">&quot;&quot;</span>;</span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#125;</span></span>
&nbsp;
<span style="color: #000000;">            protected function submitBtn_clickHandler<span style="color: #66cc66;">&#40;</span>evt:MouseEvent<span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                Validator.validateAll<span style="color: #66cc66;">&#40;</span>valArr<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#125;</span></span>
<span style="color: #000000;">        <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Array</span> id=<span style="color: #ff0000;">&quot;valArr&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:StringValidator</span> source=<span style="color: #ff0000;">&quot;{username}&quot;</span> property=<span style="color: #ff0000;">&quot;text&quot;</span> required=<span style="color: #ff0000;">&quot;true&quot;</span> minLength=<span style="color: #ff0000;">&quot;4&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:StringValidator</span> source=<span style="color: #ff0000;">&quot;{password1}&quot;</span> property=<span style="color: #ff0000;">&quot;text&quot;</span> required=<span style="color: #ff0000;">&quot;true&quot;</span> minLength=<span style="color: #ff0000;">&quot;4&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Array</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Form</span> id=<span style="color: #ff0000;">&quot;frm&quot;</span> defaultButton=<span style="color: #ff0000;">&quot;{submitBtn}&quot;</span> backgroundColor=<span style="color: #ff0000;">&quot;#EEEEEE&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:FormHeading</span> label=<span style="color: #ff0000;">&quot;Spark Form Heading&quot;</span> backgroundColor=<span style="color: #ff0000;">&quot;haloSilver&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:FormItem</span> sequenceLabel=<span style="color: #ff0000;">&quot;1.&quot;</span> label=<span style="color: #ff0000;">&quot;Username:&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:helpContent</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Label</span> text=<span style="color: #ff0000;">&quot;user@domain.com&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:helpContent</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:TextInput</span> id=<span style="color: #ff0000;">&quot;username&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:FormItem</span> sequenceLabel=<span style="color: #ff0000;">&quot;2.&quot;</span> label=<span style="color: #ff0000;">&quot;Password:&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:helpContent</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Label</span> text=<span style="color: #ff0000;">&quot;weak&quot;</span> color=<span style="color: #ff0000;">&quot;red&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:helpContent</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:TextInput</span> id=<span style="color: #ff0000;">&quot;password1&quot;</span> displayAsPassword=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:FormItem</span> sequenceLabel=<span style="color: #ff0000;">&quot;3.&quot;</span> label=<span style="color: #ff0000;">&quot;Confirm password:&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:helpContent</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:HGroup</span><span style="color: #7400FF;">&gt;</span></span>
                    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Label</span> text=<span style="color: #ff0000;">&quot;One&quot;</span> color=<span style="color: #ff0000;">&quot;red&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Label</span> text=<span style="color: #ff0000;">&quot;Two&quot;</span> color=<span style="color: #ff0000;">&quot;blue&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:HGroup</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:helpContent</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:TextInput</span> id=<span style="color: #ff0000;">&quot;password2&quot;</span> displayAsPassword=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:layout</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:HorizontalLayout</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:layout</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Button</span> id=<span style="color: #ff0000;">&quot;resetBtn&quot;</span> label=<span style="color: #ff0000;">&quot;Reset&quot;</span> click=<span style="color: #ff0000;">&quot;resetBtn_clickHandler(event);&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Button</span> id=<span style="color: #ff0000;">&quot;submitBtn&quot;</span> label=<span style="color: #ff0000;">&quot;Submit&quot;</span> click=<span style="color: #ff0000;">&quot;submitBtn_clickHandler(event);&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Form</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p class="alert">This entry is based on a beta version of the Flex Hero SDK and therefore is very likely to change as development of the Flex SDK continues. The API can (and will) change causing examples to possibly not compile in newer versions of the Flex Hero SDK.</p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Displaying the error indicator on a Spark FormItem container in Flex Hero on FlexExamples.com',url: 'http://blog.flexexamples.com/2010/08/30/displaying-the-error-indicator-on-a-spark-formitem-container-in-flex-hero/',contentID: 'post-3323',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'errorString,Hero,validateAll()',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2010/08/30/displaying-the-error-indicator-on-a-spark-formitem-container-in-flex-hero/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Trimming strings using the Flex StringUtil class&#8217;s trim() method</title>
		<link>http://blog.flexexamples.com/2007/09/07/trimming-strings-using-the-flex-stringutil-classs-trim-method/</link>
		<comments>http://blog.flexexamples.com/2007/09/07/trimming-strings-using-the-flex-stringutil-classs-trim-method/#comments</comments>
		<pubDate>Fri, 07 Sep 2007 07:22:58 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[EmailValidator]]></category>
		<category><![CDATA[StringUtil]]></category>
		<category><![CDATA[StringValidator]]></category>
		<category><![CDATA[Validator]]></category>
		<category><![CDATA[.errorTip]]></category>
		<category><![CDATA[trim()]]></category>
		<category><![CDATA[validateAll()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2007/09/07/trimming-strings-using-the-flex-stringutil-classs-trim-method/</guid>
		<description><![CDATA[<p>The following example shows you how to use the StringUtil.trim() method in Flex to remove leading and trailing whitespace from form fields before validating user input. This allows you to make sure that user&#8217;s don&#8217;t try anything sneaky like enter spaces instead of characters to bypass any minimum length validation you may have in place [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows you how to use the <code>StringUtil.trim()</code> method in Flex to remove leading and trailing whitespace from form fields before validating user input. This allows you to make sure that user&#8217;s don&#8217;t try anything sneaky like enter spaces instead of characters to bypass any minimum length validation you may have in place when validating data.</p>
<p>Full code after the jump.</p>
<p><span id="more-159"></span></p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- http://blog.flexexamples.com/2007/09/07/trimming-strings-using-the-flex-stringutil-classs-trim-method/ --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Application</span> name=<span style="color: #ff0000;">&quot;StringUtil_trim_test&quot;</span></span>
<span style="color: #000000;">        xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span></span>
<span style="color: #000000;">        layout=<span style="color: #ff0000;">&quot;vertical&quot;</span></span>
<span style="color: #000000;">        verticalAlign=<span style="color: #ff0000;">&quot;middle&quot;</span></span>
<span style="color: #000000;">        backgroundColor=<span style="color: #ff0000;">&quot;white&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Style</span><span style="color: #7400FF;">&gt;</span></span>
        .errorTip {
            borderColor: haloBlue;
        }
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Style</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #339933;">&lt;mx:Script&gt;</span>
<span style="color: #339933;">        &lt;![CDATA[</span>
<span style="color: #339933;">            import mx.controls.Alert;</span>
<span style="color: #339933;">            import mx.controls.TextInput;</span>
<span style="color: #339933;">            import mx.utils.StringUtil;</span>
<span style="color: #339933;">            import mx.validators.Validator;</span>
&nbsp;
<span style="color: #339933;">            private function trimStr(evt:FocusEvent):void {</span>
<span style="color: #339933;">                var ti:TextInput = TextInput(evt.currentTarget);</span>
<span style="color: #339933;">                ti.text = StringUtil.trim(ti.text);</span>
<span style="color: #339933;">            }</span>
&nbsp;
<span style="color: #339933;">            private function validateForm():void {</span>
<span style="color: #339933;">                var errors:Array = Validator.validateAll(validatorArray);</span>
<span style="color: #339933;">                if (errors.length) {</span>
<span style="color: #339933;">                    Alert.show(&quot;Form is somehow invalid.&quot;, &quot;INVALID&quot;);</span>
<span style="color: #339933;">                } else {</span>
<span style="color: #339933;">                    Alert.show(&quot;Form is valid.&quot;, &quot;VALID&quot;);</span>
<span style="color: #339933;">                }</span>
<span style="color: #339933;">            }</span>
<span style="color: #339933;">        ]]&gt;</span>
<span style="color: #339933;">    &lt;/mx:Script&gt;</span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Array</span> id=<span style="color: #ff0000;">&quot;validatorArray&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:StringValidator</span> id=<span style="color: #ff0000;">&quot;firstNameValidator&quot;</span></span>
<span style="color: #000000;">                source=<span style="color: #ff0000;">&quot;{firstName}&quot;</span></span>
<span style="color: #000000;">                property=<span style="color: #ff0000;">&quot;text&quot;</span></span>
<span style="color: #000000;">                required=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:StringValidator</span> id=<span style="color: #ff0000;">&quot;lastNameValidator&quot;</span></span>
<span style="color: #000000;">                source=<span style="color: #ff0000;">&quot;{lastName}&quot;</span></span>
<span style="color: #000000;">                property=<span style="color: #ff0000;">&quot;text&quot;</span></span>
<span style="color: #000000;">                required=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:EmailValidator</span> id=<span style="color: #ff0000;">&quot;emailValidator&quot;</span></span>
<span style="color: #000000;">                source=<span style="color: #ff0000;">&quot;{email}&quot;</span></span>
<span style="color: #000000;">                property=<span style="color: #ff0000;">&quot;text&quot;</span></span>
<span style="color: #000000;">                required=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Array</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Form</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span> label=<span style="color: #ff0000;">&quot;First name:&quot;</span> required=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:TextInput</span> id=<span style="color: #ff0000;">&quot;firstName&quot;</span> focusOut=<span style="color: #ff0000;">&quot;trimStr(event);&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span> label=<span style="color: #ff0000;">&quot;Last name:&quot;</span> required=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:TextInput</span> id=<span style="color: #ff0000;">&quot;lastName&quot;</span> focusOut=<span style="color: #ff0000;">&quot;trimStr(event);&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span> label=<span style="color: #ff0000;">&quot;Email:&quot;</span> required=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:TextInput</span> id=<span style="color: #ff0000;">&quot;email&quot;</span> focusOut=<span style="color: #ff0000;">&quot;trimStr(event);&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Button</span> label=<span style="color: #ff0000;">&quot;Submit&quot;</span> click=<span style="color: #ff0000;">&quot;validateForm();&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Form</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/StringUtil_trim_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/StringUtil_trim_test/bin/main.html" width="100%" height="200"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Trimming strings using the Flex StringUtil class\&#039;s trim() method on FlexExamples.com',url: 'http://blog.flexexamples.com/2007/09/07/trimming-strings-using-the-flex-stringutil-classs-trim-method/',contentID: 'post-159',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: '.errorTip,trim(),validateAll()',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2007/09/07/trimming-strings-using-the-flex-stringutil-classs-trim-method/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Validating Flex forms using the Validator classes</title>
		<link>http://blog.flexexamples.com/2007/08/13/validating-flex-forms-using-the-validator-classes/</link>
		<comments>http://blog.flexexamples.com/2007/08/13/validating-flex-forms-using-the-validator-classes/#comments</comments>
		<pubDate>Tue, 14 Aug 2007 06:23:19 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[StringValidator]]></category>
		<category><![CDATA[ValidationResultEvent]]></category>
		<category><![CDATA[Validators]]></category>
		<category><![CDATA[ZipCodeValidator]]></category>
		<category><![CDATA[validateAll()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2007/08/13/validating-flex-forms-using-the-validator-classes/</guid>
		<description><![CDATA[<p>Another quick post on validating a form using the StringValidator, NumberValidator, ZipCodeValidator and Validator classes. Not sure if this is the best method, but I used the NumberValidator to validate that a ComboBox has a valid selection (the selectedIndex property was equal to or greater than 0), and I used a combination of StringValidator and [...]]]></description>
			<content:encoded><![CDATA[<p>Another quick post on validating a form using the StringValidator, NumberValidator, ZipCodeValidator and Validator classes. Not sure if this is the best method, but I used the NumberValidator to validate that a ComboBox has a valid selection (the selectedIndex property was equal to or greater than 0), and I used a combination of StringValidator and ZipCodeValidator to make sure that the user enters a US Zip+4 zip code.</p>
<p>Got some good Flex Validator tips? Leave em in the comments!</p>
<p>Full code after the jump.</p>
<p><span id="more-83"></span></p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- http://blog.flexexamples.com/2007/08/13/validating-flex-forms-using-the-validator-classes/ --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Application</span> xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span></span>
<span style="color: #000000;">    layout=<span style="color: #ff0000;">&quot;vertical&quot;</span></span>
<span style="color: #000000;">    verticalAlign=<span style="color: #ff0000;">&quot;middle&quot;</span></span>
<span style="color: #000000;">    backgroundColor=<span style="color: #ff0000;">&quot;white&quot;</span></span>
<span style="color: #000000;">    creationComplete=<span style="color: #ff0000;">&quot;init();&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #339933;">&lt;mx:Script&gt;</span>
<span style="color: #339933;">        &lt;![CDATA[</span>
<span style="color: #339933;">            import mx.validators.Validator;</span>
<span style="color: #339933;">            import mx.events.ValidationResultEvent;</span>
<span style="color: #339933;">            import mx.validators.ZipCodeValidatorDomainType;</span>
<span style="color: #339933;">            import mx.controls.Alert;</span>
&nbsp;
<span style="color: #339933;">            [Bindable]</span>
<span style="color: #339933;">            private var validatorArr:Array;</span>
&nbsp;
<span style="color: #339933;">            private function init():void {</span>
<span style="color: #339933;">                validatorArr = new Array();</span>
<span style="color: #339933;">                validatorArr.push(shippingName_stringValidator);</span>
<span style="color: #339933;">                validatorArr.push(shippingAddress1_stringValidator);</span>
<span style="color: #339933;">                validatorArr.push(shippingCity_stringValidator);</span>
<span style="color: #339933;">                validatorArr.push(shippingState_numberValidator);</span>
<span style="color: #339933;">                validatorArr.push(shippingZipCode_zipCodeValidator);</span>
<span style="color: #339933;">                validatorArr.push(shippingZipCode_stringValidator);</span>
<span style="color: #339933;">            }</span>
&nbsp;
<span style="color: #339933;">            private function validateForm(evt:MouseEvent):void {</span>
<span style="color: #339933;">                var validatorErrorArray:Array = Validator.validateAll(validatorArr);;</span>
<span style="color: #339933;">                var isValidForm:Boolean = validatorErrorArray.length == 0;</span>
<span style="color: #339933;">                if (isValidForm) {</span>
<span style="color: #339933;">                    Alert.show(&quot;The form is valid!&quot;, &quot;Valid form...&quot;);</span>
<span style="color: #339933;">                } else {</span>
<span style="color: #339933;">                    var err:ValidationResultEvent;</span>
<span style="color: #339933;">                    var errorMessageArray:Array = [];</span>
<span style="color: #339933;">                    for each (err in validatorErrorArray) {</span>
<span style="color: #339933;">                        var errField:String = FormItem(err.currentTarget.source.parent).label</span>
<span style="color: #339933;">                        errorMessageArray.push(errField + &quot;: &quot; + err.message);</span>
<span style="color: #339933;">                    }</span>
<span style="color: #339933;">                    Alert.show(errorMessageArray.join(&quot;\n\n&quot;), &quot;Invalid form...&quot;, Alert.OK);</span>
<span style="color: #339933;">                }</span>
<span style="color: #339933;">            }</span>
&nbsp;
<span style="color: #339933;">            private function resetForm(evt:MouseEvent):void {</span>
<span style="color: #339933;">                shippingName.text = &quot;&quot;;</span>
<span style="color: #339933;">                shippingAddress1.text = &quot;&quot;;</span>
<span style="color: #339933;">                shippingAddress2.text = &quot;&quot;;</span>
<span style="color: #339933;">                shippingCity.text = &quot;&quot;;</span>
<span style="color: #339933;">                shippingState.selectedIndex = -1;</span>
<span style="color: #339933;">                shippingZipCode.text = &quot;&quot;;</span>
<span style="color: #339933;">            }</span>
<span style="color: #339933;">        ]]&gt;</span>
<span style="color: #339933;">    &lt;/mx:Script&gt;</span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:XMLList</span> id=<span style="color: #ff0000;">&quot;statesXMLList&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;">&lt;state label=<span style="color: #ff0000;">&quot;California&quot;</span> data=<span style="color: #ff0000;">&quot;CA&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;">&lt;state label=<span style="color: #ff0000;">&quot;Oregon&quot;</span> data=<span style="color: #ff0000;">&quot;OR&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:XMLList</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:StringValidator</span> id=<span style="color: #ff0000;">&quot;shippingName_stringValidator&quot;</span></span>
<span style="color: #000000;">        source=<span style="color: #ff0000;">&quot;{shippingName}&quot;</span></span>
<span style="color: #000000;">        property=<span style="color: #ff0000;">&quot;text&quot;</span></span>
<span style="color: #000000;">        minLength=<span style="color: #ff0000;">&quot;2&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:StringValidator</span> id=<span style="color: #ff0000;">&quot;shippingAddress1_stringValidator&quot;</span></span>
<span style="color: #000000;">        source=<span style="color: #ff0000;">&quot;{shippingAddress1}&quot;</span></span>
<span style="color: #000000;">        property=<span style="color: #ff0000;">&quot;text&quot;</span></span>
<span style="color: #000000;">        minLength=<span style="color: #ff0000;">&quot;2&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:StringValidator</span> id=<span style="color: #ff0000;">&quot;shippingCity_stringValidator&quot;</span></span>
<span style="color: #000000;">        source=<span style="color: #ff0000;">&quot;{shippingCity}&quot;</span></span>
<span style="color: #000000;">        property=<span style="color: #ff0000;">&quot;text&quot;</span></span>
<span style="color: #000000;">        minLength=<span style="color: #ff0000;">&quot;2&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:NumberValidator</span> id=<span style="color: #ff0000;">&quot;shippingState_numberValidator&quot;</span></span>
<span style="color: #000000;">        source=<span style="color: #ff0000;">&quot;{shippingState}&quot;</span></span>
<span style="color: #000000;">        lowerThanMinError=<span style="color: #ff0000;">&quot;This field is required.&quot;</span></span>
<span style="color: #000000;">        property=<span style="color: #ff0000;">&quot;selectedIndex&quot;</span></span>
<span style="color: #000000;">        minValue=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:ZipCodeValidator</span> id=<span style="color: #ff0000;">&quot;shippingZipCode_zipCodeValidator&quot;</span></span>
<span style="color: #000000;">        source=<span style="color: #ff0000;">&quot;{shippingZipCode}&quot;</span></span>
<span style="color: #000000;">        property=<span style="color: #ff0000;">&quot;text&quot;</span></span>
<span style="color: #000000;">        requiredFieldError=<span style="color: #ff0000;">&quot;Please enter a zip code in ZIP+4 format.&quot;</span></span>
<span style="color: #000000;">        domain=<span style="color: #ff0000;">&quot;{ZipCodeValidatorDomainType.US_ONLY}&quot;</span>  <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:StringValidator</span> id=<span style="color: #ff0000;">&quot;shippingZipCode_stringValidator&quot;</span></span>
<span style="color: #000000;">        source=<span style="color: #ff0000;">&quot;{shippingZipCode}&quot;</span></span>
<span style="color: #000000;">        property=<span style="color: #ff0000;">&quot;text&quot;</span></span>
<span style="color: #000000;">         tooShortError=<span style="color: #ff0000;">&quot;Please enter a zip code in ZIP+4 format.&quot;</span></span>
<span style="color: #000000;">        minLength=<span style="color: #ff0000;">&quot;10&quot;</span> maxLength=<span style="color: #ff0000;">&quot;10&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Form</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormHeading</span> label=<span style="color: #ff0000;">&quot;Shipping Information&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span> required=<span style="color: #ff0000;">&quot;true&quot;</span> label=<span style="color: #ff0000;">&quot;Name&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:TextInput</span> id=<span style="color: #ff0000;">&quot;shippingName&quot;</span> maxChars=<span style="color: #ff0000;">&quot;96&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span> required=<span style="color: #ff0000;">&quot;true&quot;</span> label=<span style="color: #ff0000;">&quot;Address&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:TextInput</span> id=<span style="color: #ff0000;">&quot;shippingAddress1&quot;</span> maxChars=<span style="color: #ff0000;">&quot;128&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span> label=<span style="color: #ff0000;">&quot;&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:TextInput</span> id=<span style="color: #ff0000;">&quot;shippingAddress2&quot;</span> maxChars=<span style="color: #ff0000;">&quot;128&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span> required=<span style="color: #ff0000;">&quot;true&quot;</span> label=<span style="color: #ff0000;">&quot;City&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:TextInput</span> id=<span style="color: #ff0000;">&quot;shippingCity&quot;</span> maxChars=<span style="color: #ff0000;">&quot;128&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span> required=<span style="color: #ff0000;">&quot;true&quot;</span> label=<span style="color: #ff0000;">&quot;State&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:ComboBox</span> id=<span style="color: #ff0000;">&quot;shippingState&quot;</span> prompt=<span style="color: #ff0000;">&quot;Please select a State...&quot;</span> selectedIndex=<span style="color: #ff0000;">&quot;-1&quot;</span> dataProvider=<span style="color: #ff0000;">&quot;{statesXMLList}&quot;</span> labelField=<span style="color: #ff0000;">&quot;@label&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span> required=<span style="color: #ff0000;">&quot;true&quot;</span> label=<span style="color: #ff0000;">&quot;ZIP Code&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:TextInput</span> id=<span style="color: #ff0000;">&quot;shippingZipCode&quot;</span> maxChars=<span style="color: #ff0000;">&quot;10&quot;</span> restrict=<span style="color: #ff0000;">&quot;0-9 \-&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:HBox</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Button</span> label=<span style="color: #ff0000;">&quot;Submit&quot;</span> click=<span style="color: #ff0000;">&quot;validateForm(event)&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Button</span> label=<span style="color: #ff0000;">&quot;Reset&quot;</span> click=<span style="color: #ff0000;">&quot;resetForm(event)&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:HBox</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Form</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/Validator_validateAll_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/Validator_validateAll_test/bin/main.html" width="100%" height="320"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Validating Flex forms using the Validator classes on FlexExamples.com',url: 'http://blog.flexexamples.com/2007/08/13/validating-flex-forms-using-the-validator-classes/',contentID: 'post-83',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'validateAll()',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2007/08/13/validating-flex-forms-using-the-validator-classes/feed/</wfw:commentRss>
		<slash:comments>45</slash:comments>
		</item>
		<item>
		<title>Using the Validators.validateAll() method to validate a form</title>
		<link>http://blog.flexexamples.com/2007/08/02/using-the-validatorsvalidateall-method-to-validate-a-form/</link>
		<comments>http://blog.flexexamples.com/2007/08/02/using-the-validatorsvalidateall-method-to-validate-a-form/#comments</comments>
		<pubDate>Thu, 02 Aug 2007 17:25:03 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[StringValidator]]></category>
		<category><![CDATA[Validator]]></category>
		<category><![CDATA[Validators]]></category>
		<category><![CDATA[enabled]]></category>
		<category><![CDATA[filter()]]></category>
		<category><![CDATA[validateAll()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2007/08/02/using-the-validatorsvalidateall-method-to-validate-a-form/</guid>
		<description><![CDATA[<p>I recently saw this issue in FlexCoders and filed a bug for the poster. Well, it turns out the bug I filed was a duplicate of an existing bug, and that bug has been fixed (in Flex 3 &#8212; codename:Moxie). So, long story longer, here&#8217;s how you can use the Validator class&#8217;s validateAll() method to [...]]]></description>
			<content:encoded><![CDATA[<p>I recently saw this issue in FlexCoders and filed a bug for the poster. Well, it turns out the bug I filed was a duplicate of an existing bug, and that bug has been fixed (in Flex 3 &#8212; codename:Moxie). So, long story longer, here&#8217;s how you can use the Validator class&#8217;s <code>validateAll()</code> method to validate a form (which may or may not have enabled validators).</p>
<p>Full code (and workaround) after the jump.</p>
<p><span id="more-47"></span></p>
<p>This bug was reportedly fixed in build 176281, so if you have an older Flex 3 build, you may need to use the Flex 2 workaround below. Or, you could go to the <a href="http://labs.adobe.com/technologies/flex/sdk/flex3sdk.html">nightly Flex 3 SDK builds page on the Adobe Labs site</a> and download a build newer than 176281, which is basically anything newer than Thursday July 12, 2007.</p>
<pre class="code" lang="actionscript">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- FLEX 3 SOLUTION --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white" creationComplete="initApp()"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.events.ValidationResultEvent;
            import mx.controls.Alert;
            import mx.validators.Validator;

            private var myValidators:Array;

            private function initApp():void {
                myValidators = [valid1, valid2];
            }

            private function clickHandler():void {
                var errors:Array = Validator.validateAll(myValidators);
                if (errors.length == 0) {
                    Alert.show("Looks valid to me.", "SUCCESS");
                }
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:StringValidator id="valid1" source="{ti1}" property="text" minLength="4" maxLength="6" /&gt;
    &lt;mx:StringValidator id="valid2" source="{ti2}" property="text" minLength="4" maxLength="6" enabled="false" /&gt;

    &lt;mx:TextInput id="ti1" /&gt;
    &lt;mx:TextInput id="ti2" /&gt;

    &lt;mx:Button label="validate" click="clickHandler()" /&gt;

&lt;/mx:Application&gt;
</pre>
<p>If you are using Flex 2.0.1 (Hotfix 2 or Hotfix 3), the easiest workaroud I&#8217;ve found is to just filter the array of validators that you pass to the <code>validateAll()</code> method so that no validators are passed if their <code>enabled</code> property is set to false. Thankfully this is pretty simple if you use the Array class&#8217;s <code>filter()</code> method, as seen below.</p>
<pre class="code" lang="actionscript">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- FLEX 2 SOLUTION --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white" creationComplete="initApp()"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.events.ValidationResultEvent;
            import mx.controls.Alert;
            import mx.validators.Validator;

            private var myValidators:Array;

            private function initApp():void {
                myValidators = [valid1, valid2].filter(filterDisabledValidators);
            }

            private function clickHandler():void {
                var errors:Array = Validator.validateAll(myValidators);
                if (errors.length == 0) {
                    Alert.show("Looks valid to me.", "SUCCESS");
                }
            }

            private function filterDisabledValidators(element:*, index:int, arr:Array):Boolean {
                return element.enabled;
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:StringValidator id="valid1" source="{ti1}" property="text" minLength="4" maxLength="6" /&gt;
    &lt;mx:StringValidator id="valid2" source="{ti2}" property="text" minLength="4" maxLength="6" enabled="false" /&gt;

    &lt;mx:TextInput id="ti1" /&gt;
    &lt;mx:TextInput id="ti2" /&gt;

    &lt;mx:Button label="validate" click="clickHandler()" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="note">For more information on the bug, and where I got the code for this post, see the bug in the public Flex bugbase at: <a href="http://bugs.adobe.com/jira/browse/SDK-9408">http://bugs.adobe.com/jira/browse/SDK-9408</a>.</p>
<p>Happy Flexing!</p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Using the Validators.validateAll() method to validate a form on FlexExamples.com',url: 'http://blog.flexexamples.com/2007/08/02/using-the-validatorsvalidateall-method-to-validate-a-form/',contentID: 'post-47',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'enabled,filter(),validateAll()',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2007/08/02/using-the-validatorsvalidateall-method-to-validate-a-form/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

