Flex validator issue
I'm working with flex 3.5 and I have a problem with a validator. I have a field that dynamically has o has not an asigned validator, the problem is that in a specific moment the field haven't the validator assigned but the textInput had a red border.
I dont know what do I have to remove the red marker?
Here is an example of my validator:
This is the validator:
<mx:CreditCardValidator id="ccV"
cardTypeSource="{cardTypeCbx.selectedItem}"
cardTypeProperty="data"
cardNumberSource="{ccNumberTextInput}"
cardNumberProperty="text" required="true"/>
I have a textInput named ccNumberTextInput and a combo named cardTypeCbx
When I have to set the 开发者_运维技巧validator:
validatorArr = new Array();
validatorArr.push(ccV);
validateForm();
And when I don't need it:
validatorArr = new Array();
validateForm();
The validateForm Function is:
private function validateForm():void
{
var validatorErrorArray:Array = Validator.validateAll(validatorArr);
isFormValid = validatorErrorArray.length == 0;
}
And I have a button that been enable or disable because it has a binding with a boolean var isFormValid.
The most weird thing is that when remove the validator the button becomes enables but the red border is still in the textInput.
Thanks in advanced.
Instead of modifying the array with the validators, you should enable/disable each validator when you need too. Because the binding between the validator and the component it validates is still there even when you don't have all the validators in your array. Then, two things can happen: either the previous validation remains, or another one could be triggered by that binding.
See http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/validators/Validator.html?filter_flex=4.1&filter_flashplayer=10.1&filter_air=2#enabled for more information.
精彩评论