yarek
yarek

Reputation: 12034

flex mobile validation: how to remove red error border?

I use validators in my flex mobile application. I want to remove the red border when validator has triggered an error.

    <mx:EmailValidator id="emailV"  source="{login_txt}" property="text"  triggerEvent="click" trigger="{connexion_btn}"  />
    <mx:StringValidator id="passwordV" source="{password_txt}" property="text"  trigger="{connexion_btn}"  triggerEvent="click" />

I tried:

target.errorString = null; // not good

Any clue ?

Upvotes: 0

Views: 1024

Answers (3)

Pavel M.
Pavel M.

Reputation: 572

Besides setting the error string to empty, I had to call showFocus(), or the red border wouldn't go away.

login.errorString = '';
login.focusManager.showFocus();

Upvotes: 0

timwjohn
timwjohn

Reputation: 377

The red glow is defined in spark.skins.spark.ErrorSkin, which is the default value of a UIComponent's errorSkin property. You can't set this property to null, but you can extend the ErrorSkin class and override the methods that generate the glow (namely, updateDisplayList and processBitmap).

I created a NullFocusSkin that I use to remove the red error glow and the blue focus glow. I set the component's errorSkin and focusSkin properties to that and hey presto - no more nasty glow, and no need to manually clear the errorString!

import spark.skins.spark.HighlightBitmapCaptureSkin;

public class NullFocusSkin extends HighlightBitmapCaptureSkin
{
    override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
    {   
        // Do nothing.
    }

    override protected function processBitmap():void
    {
        // Do nothing.
    }
}

Upvotes: 0

JeffryHouser
JeffryHouser

Reputation: 39408

Usually I would set the errorString to an empty string; and I do that on the instance of the component with the red string on it. I believe in that case, it would be your trigger component:

login_txt.errorString = '';
password_txt.errorString = '';

I'm unclear based on the limited code provided if the target you are setting the errorString on will be the same as the actual component specified as the validator source. It could be, we just aren't provided enough information to know for sure.

Upvotes: 1

Related Questions