This content has been marked as final. Show 6 replies
A little while back I needed very specific number validation and tooltip behavior. I wound up rewriting a major portion of the NumberValidator class and I created a custom tooltip class.
For your case, I would say that if you don't need different number validation than what the NumberValidator class provides, then simply set the ToolTipManager.enabled = false. Of course, if you have multiple fields in the same view, this prohibits other fields from using tooltips, but you could enable it on a per field basis in a custom tooltip class.
My custom tooltip class disabled the ToolTipManager, then I used ToolTipManager.createToolTip and ToolTipManager.destroyToolTip under very specific circumstances to display the tooltips for specific input fields using event.currentTarget of the ValidationResultEvent.
My functionality always called for the focus border to be drawn based on the errorString, so I'm not quite sure how you want to handle that. Look at the drawFocus() method of UIComponent class to see if that'll disable it for you.
Hope this helps.
I will have to try what you suggested. That might work to an extent . The field I want to validate needs to be an integer.So I would need that validation and tooltip default behaviour for that ,BUT the field is not mandatory.So I don't want the tooltip and the validation default behaviour[red box] that exists for a mandatory field.
There are a couple of fields and only one of them needs to be entered.No specific field is mandatory.So the behaviour associated with 'mandatory field' should be disabled ,tooltip,redbox. If nothing is entered in this field, it should still be 'valid' and not invalid.
Are you validating the field on a submit button click? My validation was actually "live" or on the change event of the TextInput component as the user typed characters. You could set the validator's "required" property to false and still get the basic validation. Have you tried:
myValidator.required = false;
If myValidator.required = false; then the validator wouldn't validate at all. I just want it not to validate when nothing is entered , i.e its not a required field. but when something is entered it should.
My validation is live too, on the 'KeyUp; event.
I tried removing val.length ==0 check in the following ,since that is what checks for the length of the object, but doesnt seem to work. Do we have to do anything other than just save when we change any framework classes because I made this change in the NumberValidator.as .
override protected function doValidation(value:Object):Array
var results:Array = super.doValidation(value);
// Return if there are errors
// or if the required property is set to <code>false</code> and length is 0.
var val:String = value ? String(value) : "";
if (results.length > 0 || ((val.length == 0) && !required))
return NumberValidator.validateNumber(this, value, null);
Ok here is what I want to know.I think by simply disabling the super.doValidation(value); in numberValidator.as , I might get what I want since the doValidation method of the validator base class simply checks if data is entered or not.
My question is if I change a framework class what exactly should I do to see that change reflected .I simply changed and saved and it doesn't seem to work. Not sure about monkey patching!
I never tried making a change to NumberValidator and saving it, so I don't have an answer there. What I did was to make the changes to the code in NumberValidator since they were so extensive, renamed it to something else and placed it in its own package within my app package structure, leaving original copyright info intact. You could probably do the same, make your changes to doValidation(), take out the line include "../core/Version.as" elsewhere in the code and change the package name within the class to the package you placed it in.
Then refer to it in your custom namespace in mxml:
<cnv:CustomNumberValidator > (or something similar)
var myNumValidator:CustomNumberValidator = new CustomNumberValidator()