1 person found this helpful
At first glance I would say that trying to combine your client-side and server-side validation into a single class like that is not a good idea. In
doForUserName() you are making an asyncronous server call. The validatorResults will get returned immediately, so by the time your handler method executes it is already too late. Rather than trying to do both sets of validation at once, remove the server-side code from this class and use it as a normal flex validator. Then in your component (or better yet in your controller class if you follow an MVC pattern) call your service method after the client side validator returns a valid result.
If i use a normal flex validator, can i still send the message to the input field, as it is done by the validator?
I don;t want to show an alert box, but cause the input field the change color and have a message highlighted when you are over the input field.
If possible how can it be done?
Once you have the message string from the server-side error, bind it to the 'errorString' property of whichever input component you want to display the error on. Doing that will give you the red border and tooltip just like if you used a validator. Just remember to set the error string back to "" to clear the message once the validation passes.