Here's a simple way:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute">

<mx:Script>
      <![CDATA[
           public function turnOff(e:Event):void
           {
                sv.enabled = false;
                test.errorString = "";
           }



           public function turnOn(e:Event):void
           {
                sv.enabled = true;
           }
      ]]>
</mx:Script>

<mx:TextInput id="test"/>

<mx:Button top="60" label="Turn Off" click="turnOff(event)"/>

<mx:Button top="60" left="100" label="Turn On" click="turnOn(event)"/>

<mx:StringValidator id="sv" required="true" source="{test}"
property="text" enabled="true"/>

</mx:Application>

-TH

--- In flexcoders@yahoogroups.com, "timgerr" <tgallag...@...> wrote:
>
> Hello all, I have a question for ya.
>
> I have a text input that I attach a string validator so the text input
is required. So I put my mouse in the box then take it out, not the box
is red. I then hit a button to turn the string validator off, but the
box remains red. How can I tell a text input to not be red anymore. Here
is some code:
>
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute">
> <mx:Script>
> <![CDATA[
> public function TurnOff(e:Event):void
> {
> sv.enabled = false;
> }
> ]]>
> </mx:Script>
> <mx:TextInput id="test"/>
> <mx:Button label="Hello"/>
> <mx:StringValidator id="sv" required="true" source="{test}"
property="text" enabled="true"/>
> </mx:Application>
>
> Thanks,
> Timgerr
>


Reply via email to