OK, so this is not trivial right off the
bat right now but it can be done. Unfortunately I don’t have time to come
up with an example that I can code quickly. Basically you need to have your
elements repeated and then capture the change event of the component that is
editing the field and trigger validation. Sound complex? It canbe J One thing you could do
is encapsulate the validation logic in your visual component itself, something
like this: MyTextInput.mxml <mx:TextInput xmlns:mx=http://www.macromedia.com/2003/mxml> <mx:String id=”value”>{text}</mx:String> <mx:StringValidator field=”value”
minLength=”5” /> <!—this validator is how you would
fill in all of the validation logic à <mx:Script> Import mx.validators.Validator; function isValid() : Boolean { return Validator.isValid(this, “value”); } </mx:TextInput> MyApplication.mxml <mx:Application xmlns:mx=http://www.macromedia.com/2003/mxml> <mx:Script> function areAllValid() : Boolean { var allValid : Boolean = true; for (var i = 0; i < edgeinput.length
&& allValid; ++i) { allValid = edgeinput[i].isValid(); } return allValid; } </mx:Script> <mx:Model
id="edgesmodel" source="edges.xml"/> <mx:Form>
<mx:FormItem
label="{edgesrepeater.currentItem.label} : "
required="true"> </mx:Application> So that’s how you could determine
that everything is valid. You could also add in additional logic for change
detection, etc. Hope this can get you started, Matt From: Jeroen De Vos
[mailto:[EMAIL PROTECTED] Hi Matt, I want the values of the edgesmodel, that
could have been modified, validated, and offcourse turn the borders of the
textinput red when they don't validate. Thanks, Jeroen. Van:
Matt Chotin [mailto:[EMAIL PROTECTED] You want each individual field validated
the same way or are you trying to validate the edgesmodel as a whole?
Validators don’t really work well with repeated elements. You can
use some of the static utility methods to set something up, but then havingit
turn the borders of the textinputs red gets more difficult. Matt From: Jeroen De Vos
[mailto:[EMAIL PROTECTED] Hello
everyone, I'm
new to Flex (started on Monday) and I'm having a lot of difficulties with validation.
Then
I use a repeater to put the information on screen:
<mx:FormItem
label="{edgesrepeater.currentItem.label} : "
required="true"> The
user can change the edge value in the textinput field, so I wrote a function
which updates the information in the model (this works fine). And
finally I would like to do validation on the value field of the edgesmodel
before I execute the program. Thanks
a lot! ________________________________ Jeroen De Vos
|
Title: New to Flex and having difficulties with validation