Validating Flex forms using the Validator classes

by Peter deHaan on August 13, 2007

in StringValidator, ValidationResultEvent, Validators, ZipCodeValidator

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.

Got some good Flex Validator tips? Leave em in the comments!

Full code after the jump.

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

View source is enabled in the following example.

{ 39 comments… read them below or add one }

1 Bruce August 14, 2007 at 6:16 am

Very nice validation example. You may want to change this line:

Alert.show(errorMessageArray.join("nn"), "Invalid form...", Alert.OK);

to

Alert.show(errorMessageArray.join("\\n"), "Invalid form...", Alert.OK);

Using “\n” will cause each error to display on its own line.

Reply

2 peterd August 14, 2007 at 6:50 am

Thanks Bruce,

Apparently I needed to put two backslashes for it to show up in the entry above. *shrug*

Reply

3 Tony September 1, 2007 at 2:13 pm

Nice Example. Perfect for what I needed.
If someone has a better way, I would love to know what it is.

Reply

4 Tony September 4, 2007 at 9:15 am

Peter,

I have a suggestion for this one that may help out in the case you are using a credit card validator. The parent is stored in a different place. You can also check out my formatting.

for each (err in validatorErrorArray) {
	var formItem:FormItem;
	///trace("ClassName",getQualifiedClassName(err.currentTarget).split("::")[1]);
	switch (getQualifiedClassName(err.currentTarget).split("::")[1]){
		case "CreditCardValidator":
			formItem = err.currentTarget.cardNumberSource.parent;
		break;
		case "StringValidator":
			formItem = err.currentTarget.source.parent;
		break;
		case "ZipCodeValidator":
			formItem = err.currentTarget.source.parent;
		break;
		default:
			formItem = new FormItem();
			formItem.label = "Misc.";
		break;
	}
    errorMessageArray.push(formItem.label   ": \\n\\t"   err.message.replace(new RegExp('\\n','g'),"\\n\\t"));
}

Regards,
Tony

Reply

5 Nice September 10, 2007 at 9:35 pm

AWESOME….

Is there a way to display the textInput Name Error message?

I changed the code, but doesn’t work for me.

from:

var errField:String = FormItem(err.currentTarget.source.parent).label

to:

var errField:String = TextInput(err.currentTarget.source.parent).id

CHEERS & THANKS

Reply

6 peterd September 11, 2007 at 12:37 am

Nice,

Not sure if you’re using the example from above or a modified version (I’ll assume its the code from above), but I can get the control’s “id” by using the following snippet from the validateForm() method:

for each (err in validatorErrorArray) {
    var errField:String = err.currentTarget.source.id;
    errorMessageArray.push(errField   ": "   err.message);
}

You should take out the “parent” from the path since I was jumping up to the FormItem control to grab the label property.

Hope that helps,

Peter

Reply

7 valentineday September 12, 2007 at 12:38 pm

Peterd, you are so cool.. Now I can get the id :)

I was wondering how to verify check box in the form, most form contents check box! -_- Base on the example above, how to add a check box and return all errors in Alert.show box? any suggestion?

have a nice day

Reply

8 peterd September 12, 2007 at 1:10 pm

valentineday,

Not strictly related to the previous example, but here is one way to use a validator to see if a check box is selected. Note that I’m validating against a <mx:Model /> here, and I’m converting the data type from a Boolean to a Number. I’m sure there are other/better ways, but I threw this together somewhat quickly.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <mx:Script>
        <![CDATA[
            import mx.events.ValidationResultEvent;
            import mx.controls.Alert;

            private function validateCheckBox():void {
                num.val = Number(agree.selected);
                var result:ValidationResultEvent = numVal.validate();

                switch (result.type) {
                    case ValidationResultEvent.INVALID:
                        agree.errorString = result.message;
                        break;
                    case ValidationResultEvent.VALID:
                        Alert.show("If you can see this, you must have selected the check box.", "Valid!!!!");
                        agree.errorString = null;
                        break;
                }
            }
        ]]>
    </mx:Script>

    <mx:Model id="num">
        <val />
    </mx:Model>

    <mx:Array>
        <mx:NumberValidator id="numVal"
                source="{num}"
                property="val"
                minValue="1"
                lowerThanMinError="Please agree before continuing." />
    </mx:Array>

    <mx:CheckBox id="agree"
            label="I have pretended to read your EULA."
            selected="false" />

    <mx:Button label="Continue"
            click="validateCheckBox();" />

</mx:Application>

Hope that helps,

Peter

Reply

9 levan September 28, 2007 at 10:01 am

I think thats to extra its easier to just write BooleanValidator here I did it quick and dirty way stripped down code from StringValidator.:

public class BooleanValidator extends Validator
{

    /**
     *  @private
     *  Loads resources for this class.
     */
    private static function loadResources():void
    {

    }

    public static function validateBoolean(validator:BooleanValidator,
                                          value:Boolean,
                                          baseField:String = null):Array
    {
        var results:Array = [];
        if (!value)
        {
            results.push(new ValidationResult(true));
            return results;
        }

        return results;
    }

    /**
     *  Constructor.
     */
    public function BooleanValidator()
    {
        super();

    }

    override protected function doValidation(value:Object):Array
    {
        var results:Array = super.doValidation(value);

        // Return if there are errors
        // or if the required property is set to false and length is 0.
        var val:String = value ? String(value) : "";
        if (results.length > 0 || ((val.length == 0) && !required))
            return results;
        else
            return BooleanValidator.validateBoolean(this, (value as Boolean), null);
    }
}

I think you are doing way too much extra just to get checkbox validate.

Reply

10 levan September 28, 2007 at 10:03 am

after that you can just do :

var temp2:BooleanValidator = new BooleanValidator();
aComp.addEventListener(Event.CHANGE,checkFields);
temp2.source=aComp;/// refference to your checkbox
temp2.property="selected";
temp2.required=true;
myValidators.addItem(temp);

Reply

11 peterd September 28, 2007 at 6:44 pm

levan,

Great tip, thanks!

Peter

Reply

12 Gareth October 19, 2007 at 7:24 pm

Does anyone know how to use the source and property fields to do a credit card validation in actionscript? I know that I can use the cardTypeSource and property and the cardNumberSource and property to do it, but I’m trying to make it more generic, and, according to the livedocs, it is possible by passing an object. However, I’ve tried just about every variation I can think of, but none of them work.

This is the part that’s confusing me

Use the source and property properties to specify a single Object. The Object should contain the following fields:

cardType – Specifies the type of credit card being validated.
In MXML, use the values: “American Express”, “Diners Club”, “Discover”, “MasterCard”, or “Visa”.
In ActionScript, use the static constants CreditCardValidatorCardType.MASTER_CARD, CreditCardValidatorCardType.VISA, or CreditCardValidatorCardType.AMERICAN_EXPRESS CreditCardValidatorCardType.DISCOVER, or CreditCardValidatorCardType.DINERS_CLUB.

cardNumber – Specifies the number of the card being validated.

I’ve done ccObj:object = { cardNumber: myCardNumField, cardType: myCardTypeField }
for the source, but then I don’t know what string to use for the property (as property appears that it has to be a string).

Anyone have any ideas?

Reply

13 peterd October 19, 2007 at 11:30 pm

Gareth,

I just whipped this up (“Creating a credit card validator in ActionScript”), although now re-reading your question I’m not sure if I answered the right thing.

Was that roughly what you were looking for? Or were you looking for something more specific to the object syntax?

Peter

Reply

14 Gareth November 1, 2007 at 1:34 pm

Hey Peter,
finally got around to this post again. Thanks for the post. That definitely makes it easier to understand. I guess what confused me previously was that the object would be the source and the properties for each would be the the actual properties of the object. I’m not sure what it was I was trying, but whatever I was doing was not working. This will definitely help.
Thanks.

Reply

15 Halfway there... March 21, 2008 at 2:10 pm

Sorry, but this is not a good example. Way too much boilerplate code and no reusability. It’s also missing some of the instant error feedback (indicate after each keystroke whether your form input is valid or invalid – come on, javascript forms can do this…) or even basic expected functionality such as having the enter key “revalidate” the input component or something.

What if you have 10 forms with 5-20 fields each? Are we supposed to copy and paste all that stuff for every field, every form? It’s not easily pulled out into a custom component.

Nice for simple cases but serious apps will demand more than this…

Reply

16 دردشة April 26, 2008 at 8:11 am

the type of credit card being validated

Reply

17 flexlingie June 19, 2008 at 3:01 pm

Great blog posting. I like the idea of a BooleanValidator!
Thanks!

Reply

18 Tanya R June 25, 2008 at 1:29 pm

Great Examples.

i have a quesiton about combobox, it seems that when the page first loads, my comboboxes are marked as invalid right away, even before the submit button is clicked.

In your sample however, they do not have the red border around them initially…. is there a way to fix it?

this is a snippit of my code:

[code]

[/code]

and

[code]

[/code]

please help me, i can’t seem to find a solution to this anywere.

Thanks!
-Tanya

Reply

19 Tanya R June 25, 2008 at 1:29 pm

oh oh, the code didn’t show… but i hope you get the main idea of my issue.

Thanks!

Reply

20 Nate R July 1, 2008 at 1:44 pm

Tanya,

Here is what I did to get the ComboBox’s border to show as red when invalid.

<mx:NumberValidator id="validator" source="{combo}" property="selectedIndex" minValue="0" invalid="changeComboBorder(event)" valid="changeComboBorder(event);" />
private function changeComboBorder(event:ValidationResultEvent):void {
  var validator:Validator = event.target as Validator;
  var comboBox:ComboBox = validator.source as ComboBox;
 
  if (event.type == ValidationResultEvent.VALID) {
    comboBox.setStyle("borderColor", 0xB7BABC);
  }
  else {
    comboBox.setStyle("borderColor", 0xFF0000);
  }
}

Hopefully this helps.

Reply

21 Aasim August 8, 2008 at 2:23 am

I guess what Tanya wanted to point was that the ComboBox control is validated on creation. The solution to her query can be achieved by setting the triggerEvent on the validator to “focusOut” of the source.

This would trigger the validation of the comboBox on moving focus from the comboBox.

code below–

<mx:NumberValidator id="comboValidator" required="true" minValue="0"
    	invalid="changeComboBorder(event)" valid="changeComboBorder(event)"
    	triggerEvent="focusOut"
    	source="{trialCombo}" property="selectedIndex" />

Reply

22 Albus January 13, 2009 at 3:30 pm

If you had a password and confirm password inputs, is there a way to set the validator to check that they are equal?

Reply

23 aughty January 19, 2009 at 6:48 am

Hi

I just have one query is there any way to reset the color of the all control when
user clicked first to submit and then to reset it still in red color.

Reply

24 Jens February 19, 2009 at 9:32 am

@Albus

I had to do the same and found a piece of code that I changed a little:

package validator
{
    import mx.validators.ValidationResult;
    import mx.validators.Validator;

    public class StringMatchValidator extends Validator {

        // Define Array for the return value of doValidation().
        private var results:Array;

		// Define compare string
		private var _matches : String = "";

		// Define mismatch error messsage
		private var _mismatchError : String = "Password Dosen't match Retype!";

        // Constructor.
        public function StringMatchValidator() {
            super();
        }

		public function set matches (s : String) : void {
			_matches = s;
		}

		public function set mismatchError (s : String) : void {
			_mismatchError = s;
		}

        // Define the doValidation() method.
        override protected function doValidation(value:Object):Array {
            //var pwd: Password = value as Password;
            var s1: String = _matches;
            var s2: String = source.text;

            results = [];
            results = super.doValidation(value);

            // Return if there are errors.
            if (results.length > 0)
                return results;

                        if(s1 == s2)
                        {
                            return results;
                        }
                        else
                        {
                            results.push(new ValidationResult(true, null, "Mismatch", _mismatchError));
                            return results;
                        }
        }
    }
}

Usage:

<validator:StringMatchValidator id="passwordMatchValidator"
        source="{password_confirm}"
        property="text"
        matches="{password.text}" />

I’m a bit of a newbie so i hope this isn’t to ugly :)

Hope this helps

Reply

25 Betard February 20, 2009 at 10:57 am

Anyone else notice that the Alert box is not resizing to accommodate all the errors? if you click and drag your mouse (like you would to select the text to copy) to the bottom, the top line disappears.

In my alert so error items that are hidden because the Alert box is not sizing big enough to view them all, and some items are line wrapping. I tried resizing the alert box manually, but this did not allow the text itself to use more space.

Any ideas?

Reply

26 Dolly March 17, 2009 at 10:13 pm

Hi,
U have given an example to validate a single check box, but how can i do it for more than two. please help me.

Reply

27 Dolly March 18, 2009 at 12:49 am

Sorry i need one more help can u also tell me how to put that error msg in an ErrorMessageArray

Reply

28 qwr April 9, 2009 at 1:32 am

etrwetwe

Reply

29 Laurence MacNeill May 11, 2009 at 9:14 am

I’m trying to validate a ZIP Code, but ONLY if the country selected is USA. Otherwise I want the validator to ignore the inputZIPCode TextInput.

Problem is, if I set source and property values in the validator, it will ALWAYS validate what’s in there. If I don’t set source and property values, it will NEVER validate what’s in there. So how do I do it manually?

Here’s my code:

private function valZIPCode():void {
  if (inputCountry.selectedItem.toString() == "USA") {
    var vResult:ValidationResultEvent = zipV.validate(inputZIPCode.text);
    if (vResult.type==ValidationResultEvent.VALID) {
      roZIPCodes.returnCityState(inputZIPCode.text.substring(0,5));
    } else {
      //It should pop up the little red Error Message here - how do I do that?
    }
  }
}

Reply

30 Cosinus May 21, 2009 at 4:03 am

The RegExp override wit username ckeck
here is the code, make the regExp mxml with the new class(id=UserV,set source=pusername,and property=text) set enabled to false. On focusOut on the username field make a server request to check if there is this username

[....]
private function loadComplete_pusername(e:Event):void{
		var xml:XML=new XML(e.target.data);
		if(xml=="yes"){
			doValidateUsername(false);
			}
		else {
			doValidateUsername(true);
		     }
 
		UserV.enabled=false;
 
	}
	private function doValidateUsername(b:Boolean):void{
	UserV.ErrUsername=b;UserV.enabled=true;UserV.validate();
 
	}
 
 
//Override RegExpValidator, so if the username is in Database and if the the entered username "respects" the regexp
 
public class UsernameValidation extends RegExpValidator
	{
		public var ErrUsername:Boolean=false;
		private var results:Array;
		private var foundMatch:Boolean = false;//true,false i didnt saw the dif (?!?)
		public function UsernameValidation()
		{
			super();
			super.expression="^[a-zA-Z][a-zA-Z0-9_.]{5,}$";
		}
		override protected function doValidation(value:Object):Array
    {
        results=[];
        results = super.doValidation(value);
        var val:String = value ? String(value) : "";
         if(results.length &gt; 0)
			{
				 foundMatch=false;
			if(super.required == true &amp;&amp; value.length == 0)
			{
			results[0].errorMessage = "Acest camp este obligatoriu !";
			}
			else
			{
				 foundMatch=false;
			results[0].errorMessage = "Numele de utilizator nu este valid";
			}
	   	 }
		 if(ErrUsername){
		 	 foundMatch=false;
		 	 results=[];
		 	 //results[0].errorMessage = "Aceast utilizator exista deja in baza de date";
	    	 results.push(new ValidationResult(ErrUsername, null, "NaN","Aceast utilizator exista deja in baza de date"));
		 }
		 else
		 {
		    if(!(results[0] as ValidationResult).isError)
		     foundMatch=true;
		 }
			//trace("RESULT "+(results[0] as ValidationResult).isError+" "+value+" RL: "+results.length);
			return results;
 
		}
 
		override protected function handleResults(errorResults:Array):ValidationResultEvent
    		{
		      super.handleResults(errorResults);
		        var result:ValidationResultEvent;
		        if (foundMatch)
		        {
		            result = new ValidationResultEvent(ValidationResultEvent.VALID);
		            result.results = errorResults;
		        }
		        else
		        {
		            result = super.handleResults(errorResults);
 
		        }
 
		        foundMatch = false;
 
		        return result;
		    }
	}

The rest depends to you, so he cant submit the form after username error.

Reply

31 Richard July 31, 2009 at 1:03 pm

Any one run across a International Zip Code Validator yet? or seen any blog on where to get all the information?

Reply

32 Lonely in Dallas August 27, 2009 at 12:25 pm

Thank you very much for your blog – I refer to it often!

Reply

33 CaptainCode October 29, 2009 at 12:30 pm

Any easier way to validate a checkbox, using code built right into the Flex framework, is to use a string validator. When it attemts to validate on the checkbox, the “selected” property is automatically coerced into a string format. See the code below for an example:

<mx:FormItem label="I agree to the terms of use" required="true">
<mx:CheckBox id="terms"/>
</mx:FormItem>
<mx:StringValidator source="{terms}" required="true" property="selected" maxLength="4" requiredFieldError="You must agree to the Terms of Use." tooLongError="You must agree to the Terms of Use."/>

Clean, simple, built-in, and best of all…. 4 lines of MXML.

Reply

34 Kethya November 11, 2009 at 2:29 am

Hi everyone,

I am try to put two validators on one control, but it doesn’t seem working well.
The logic is here.
I put requireValidator and emailValidator on a textBox.
when I click on “myButton” do validation.
- My expectation is:
if I don’t in put any thing we have required validator error raise
if I input some text but not match email pattern it will have emailValidator error raise
- My result:
if I don’t input any text requiredFieldValidator raise (correct)
if I input text but not follow email pattern the emailValidator raise but it doesn’t draw red rectangle around my text input and doesn’t show the validate message

Please anyone helps,

Thanks

Kethya

Here is my sample code:
====================================

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute”>
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.validators.Validator;
import mx.validators.EmailValidator;
import com.vecteurplus.sfa.util.validators.RequiredFieldValidator;
private var _vList:Array;
private function hBoxInit():void {
var require:RequiredFieldValidator = new RequiredFieldValidator();
var email:EmailValidator = new EmailValidator();

require.required = true;
require.property = "text";
require.source = myText;

email.required = false;
email.property = "text";
email.source = myText;

_vList = new Array();
_vList.push(require);
_vList.push(email);
}

private function myButton_clickHandler():void {
var result:Array = Validator.validateAll(_vList);
if (result) {
Alert.show("there's error");
}
}
]]>
</mx:Script>
<mx:HBox creationComplete=”hBoxInit()”>
<mx:TextInput id=”myText”/>
<mx:Button id=”myButton”
label=”myButton”
click=”myButton_clickHandler()”/>
</mx:HBox>
</mx:Application>

Reply

35 Sameera Sandaruwan November 24, 2009 at 2:54 am

1. TextInput creates dynamically

textInputBox = new MyTextInput;
textInputBox.restrict = "0-9.";
textInputBox.maxChars = 24;
amountValidator = new NumberValidator();
amountValidator.source = textInputBox;
amountValidator.property = "text";
amountValidator.allowNegative = false;
amountValidator.domain = "real";
amountValidator.precision = 4;
amountValidator.required = false;
amountValidator.maxValue = 999999999999.9999;
amountValidator.trigger = textInputBox;
amountValidator.triggerEvent = Event.CHANGE;
amountValidator.addEventListener(ValidationResultEvent.VALID, amountValid);
amountValidator.addEventListener(ValidationResultEvent.INVALID, amountInvalid);
 
private function amountValid(event:ValidationResultEvent):void
{
    valid = true;
    fieldsValidated = true;
}
 
private function amountInvalid(event:ValidationResultEvent):void
{
    valid = false;
    fieldsValidated = true;
}

2. As mention in the creation, when we exceed the limit, it shows error my red color border, and the same time if you delete them by DEL key when it come to the given acceptable limit, automatically become to green soon.
3. Leave from the field and change values of another textinput(this is just a textinput, this is a form there are some more form elemets), then come back to value exceeded textfield by SHIFT+TABS and remove the additional entered numbers, when you come to green soon your value is accepted.
4.Now again enter more values and now you are in the warn zone, then leave from the field and do the few changes in other form elements.
5. Then come back to the value exceeded text filed by MOUSE CLICK, and start delete from DEL, even though you removed additional values, still fields shows that you are in warn zone.

Actual Results:
Even when remove additional numbers,still field is Red

Expected Results:
if remove additional numbers, field should come its normal status.

Picture of this issue can be viewed at http://bugs.adobe.com/jira/browse/SDK-24372

Reply

36 Anonymous December 9, 2009 at 7:07 am

The index for the NumberValidator is off – it doesn’t require a selection if left at 0 that should be changed to 1

Reply

37 Tim December 15, 2009 at 6:13 pm

Anybody who can help me?
I want to validate the password ,which the confirm password is right for the password ?

Reply

38 Marc de Kwant January 30, 2010 at 1:22 am

instead of using an init function to push all validators into an array, I would do this:

<mx:ArrayCollection>
   <mx:ZipCodeValidator id="shippingZipCode_zipCodeValidator"
        source="{shippingZipCode}"
        property="text"
        requiredFieldError="Please enter a zip code in ZIP+4 format."
        domain="{ZipCodeValidatorDomainType.US_ONLY}"  />
 
    <mx:StringValidator id="shippingZipCode_stringValidator"
        source="{shippingZipCode}"
        property="text"
         tooShortError="Please enter a zip code in ZIP+4 format."
        minLength="10" maxLength="10" />
</mx:ArrayCollection>

Kind regards,

Marc

Reply

39 Anonymous February 21, 2010 at 10:42 pm

Leave a Comment

Sorry, this blog is terrible at eating HTML comments.
If you're pasting any HTML/XML/MXML code, you need to convert your < characters to &lt; and your > characters to &gt; .

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Anti-Spam Protection by WP-SpamFree

Previous post:

Next post: