This content has been marked as final. Show 8 replies
For the following example:
Note : [ Assume that Model and Validator are defined probably ]
<mx:Button label="Send" click="mx.validators.Validator.isValid( this, 'settingsModel' ); " />
If I want to send to inputs as parameters then I have to modify the above to be like this
<mx:Button label="Send" click="mx.validators.Validator.isValid( this, 'settingsModel' ); add(input1.Text,input2.Text)" />
Flex will validate the inputs then it will send them to add method, Is that right ???
I've not worked with validators, but the code looks ok.
It works, thanks for your reply.
The last question here, can I play with <mx:Model> content programmatically ??? and how ???
Give your Model an id: <mx:Model id="myModel" ...
Then do something like:
var sFirstName:String = myModel.employees.firstname;
seem fine but it doesnot work with me, here is my code
I want to change the structure of Model programmatically, so in particular moment or " once I disable some components " I do not want from the Validator to keep the checking for those component value.
In the example here, I have tried to change the structure of CheckModel. First time, Validator will check username and password, Then I have tried to force the validator to check password and link only. But its fail.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx=" http://www.macromedia.com/2003/mxml">
usernameFormItem.required = false;
CheckModel.USERNAME.firstname = link.text;
if(temp == true)
<mx bject id="CheckModel" />
<mx:StringValidator field="CheckModel.USERNAME" minLength="4" maxLength="12"/>
<mx:StringValidator field="CheckModel.PASSWORD" minLength="4" maxLength="12"/>
<mx anel title="Login" width="400" height="200" marginBottom="20" marginLeft="20" marginRight="20" marginTop="20">
<mx:FormItem id="usernameFormItem" label="user name :" required="true">
<mx:TextInput id="username" />
<mx:FormItem label="password :" required="true">
<mx:TextInput id="password" />
<mx:FormItem label="link :" required="true">
<mx:TextInput id="link" />
<mx:HBox><mx:Button id="okButton" label="OK" click="checkValidity();" /><mx:Button id="cancelButton" label="Cancel" /></mx:HBox>
Is there any way to do what I want exactly?
Disable a particular TextInput and remove its state to be check by StringValidator.
Please, any help would be appreciated
I have found a way to do that. Just by using
mx.validators.Validator.disable & mx.validators.Validator.enable
Now I can say I have finished the half of my application. But, still need to know how to prevent some characters like @, !, $, ?
Thanks in advance
I think I can do it by the customized validator