[flexcoders] Re: Form validation before submitting...
Just one technique: using AS, throw the validators into an ArrayCollection on creationComplete. Before you submit, loop through the validators and execute the validate() function on each. If one fails, bail out. The docs can show you how to work with ValidationResultEvent. Also remember that all validators can be cast as Validator; regardles of the subclass. -TH --- In flexcoders@yahoogroups.com, Laurence MacNeill lmacne...@... wrote: At 08:13 PM 5/18/2009, you wrote: Almost seems like you'd want to loop through the validators instead, huh? -TH Didn't know I could do that... How would I go about doing that? Thanks, Laurence MacNeill Mableton, Georgia, USA
[flexcoders] Re: Form validation before submitting...
first you trying to use numChildren as a method but it is not it is a property which return int value and it is read-only so remove the () in the loop second what is errorString ???
[flexcoders] Re: Form validation before submitting...
import mx.core.UIComponent; private function formIsValid():Boolean { var validForm:Boolean = true; for (var i:int = 0; i this.numChildren; i++) { if ( UIComponent(this.getChildAt(i)).errorString != ) { validForm = false; } } return validForm; } -TH --- In flexcoders@yahoogroups.com, sminrana sminr...@... wrote: first you trying to use numChildren as a method but it is not it is a property which return int value and it is read-only so remove the () in the loop second what is errorString ???
Re: [flexcoders] Re: Form validation before submitting...
At 04:24 PM 5/18/2009, you wrote: first you trying to use numChildren as a method but it is not it is a property which return int value and it is read-only so remove the () in the loop second what is errorString ??? Oh LOL -- now I feel like an idiot. Of course, it's a property not a method. Thanks for pointing that out. :-) And, errorString is what gets set when a validator pops up one of those little red error messages. You can set it yourself, too, if you want, after manually using a valdiator to check for a .VALID condition. Laurence MacNeill Mableton, Georgia, USA
Re: [flexcoders] Re: Form validation before submitting...
At 04:54 PM 5/18/2009, you wrote: import mx.core.UIComponent; private function formIsValid():Boolean { var validForm:Boolean = true; for (var i:int = 0; i this.numChildren; i++) { if ( UIComponent(this.getChildAt(i)).errorString != ) { validForm = false; } } return validForm; } -TH Thanks, Tim! Exactly what I was looking for. Much obliged. Laurence MacNeill Mableton, Georgia, USA
Re: [flexcoders] Re: Form validation before submitting...
Why not stop and return when validForm just turns false, like this: On Mon, May 18, 2009 at 5:54 PM, Tim Hoff timh...@aol.com wrote: * import * mx.core.UIComponent; *private* *function* formIsValid():Boolean { * for* (*var* i:int = 0; i *this*.numChildren; i++) { * if* ( UIComponent(*this*.getChildAt(i)).errorString != ** ) { *return* *false*; } } ***return* *true*; } -TH --- In flexcoders@yahoogroups.com, sminrana sminr...@... wrote: first you trying to use numChildren as a method but it is not it is a property which return int value and it is read-only so remove the () in the loop second what is errorString ??? -- Ivan Perez - Desenvolvimento Tecnológico TecSinapse - www.tecsinapse.com.br 11 9324-0097 / 19 8812-0809
[flexcoders] Re: Form validation before submitting...
Yep, good re-factor. -TH --- In flexcoders@yahoogroups.com, Ivan Perez manope...@... wrote: Why not stop and return when validForm just turns false, like this: On Mon, May 18, 2009 at 5:54 PM, Tim Hoff timh...@... wrote: * import * mx.core.UIComponent; *private* *function* formIsValid():Boolean { * for* (*var* i:int = 0; i *this*.numChildren; i++) { * if* ( UIComponent(*this*.getChildAt(i)).errorString != ** ) { *return* *false*; } } * **return* *true*; } -TH --- In flexcoders@yahoogroups.com, sminrana sminrana@ wrote: first you trying to use numChildren as a method but it is not it is a property which return int value and it is read-only so remove the () in the loop second what is errorString ??? -- Ivan Perez - Desenvolvimento Tecnológico TecSinapse - www.tecsinapse.com.br 11 9324-0097 / 19 8812-0809
Re: [flexcoders] Re: Form validation before submitting...
At 05:13 PM 5/18/2009, you wrote: Why not stop and return when validForm just turns false, like this: On Mon, May 18, 2009 at 5:54 PM, Tim Hoff mailto:timh...@aol.comtimh...@aol.com wrote: import mx.core.UIComponent; private function formIsValid():Boolean { for (var i:int = 0; i this.numChildren; i++) { if ( UIComponent(this.getChildAt(i)).errorString != ) { return false; } } return true; } Doesn't work for me, either way, unfortunately... For some reason it's not returning false when there are errorStrings... It's allowing the form to submit, even though I can clearly see the red border(s) around the textInput(s). Any ideas?
[flexcoders] Re: Form validation before submitting...
Are you sure that you are looking for the children in the correct parent? Worked for me. -TH --- In flexcoders@yahoogroups.com, Laurence MacNeill lmacne...@... wrote: At 05:13 PM 5/18/2009, you wrote: Why not stop and return when validForm just turns false, like this: On Mon, May 18, 2009 at 5:54 PM, Tim Hoff mailto:timh...@...timhoff@... wrote: import mx.core.UIComponent; private function formIsValid():Boolean { for (var i:int = 0; i this.numChildren; i++) { if ( UIComponent(this.getChildAt(i)).errorString != ) { return false; } } return true; } Doesn't work for me, either way, unfortunately... For some reason it's not returning false when there are errorStrings... It's allowing the form to submit, even though I can clearly see the red border(s) around the textInput(s). Any ideas?
Re: [flexcoders] Re: Form validation before submitting...
At 07:56 PM 5/18/2009, you wrote: Are you sure that you are looking for the children in the correct parent? Worked for me. -TH Ahh -- that's probably it. All the textInputs I'm looking for are in a Form. Which makes them children of the Form? Or children of each FormItem tag? How would I loop thru all those? Thanks, Laurence MacNeill Mableton, Georgia, USA
[flexcoders] Re: Form validation before submitting...
Almost seems like you'd want to loop through the validators instead, huh? -TH --- In flexcoders@yahoogroups.com, Laurence MacNeill lmacne...@... wrote: At 07:56 PM 5/18/2009, you wrote: Are you sure that you are looking for the children in the correct parent? Worked for me. -TH Ahh -- that's probably it. All the textInputs I'm looking for are in a Form. Which makes them children of the Form? Or children of each FormItem tag? How would I loop thru all those? Thanks, Laurence MacNeill Mableton, Georgia, USA
Re: [flexcoders] Re: Form validation before submitting...
At 08:13 PM 5/18/2009, you wrote: Almost seems like you'd want to loop through the validators instead, huh? -TH Didn't know I could do that... How would I go about doing that? Thanks, Laurence MacNeill Mableton, Georgia, USA