Does the validator fire when you check the checkbox and it’s just that the error doesn’t clear?  Or does the validator not fire when you click on the checkbox?

 

If the first it sounds like a bug, you could workaround it by adding a validate handler and setting the errorString on the checkbox to null if there are no errors.

 

<customValidators:CheckboxRequiredValidator
field="fieldValues.DonationConfirmation" required="true" validate=”if (!event.validator.hasErrors()) DonationConfirmation.errorString = null;”/>

 

I think that the Checkbox does clear its error messages though so I’d make sure that your validator is really firing and doing the right thing.

 

Matt


From: [email protected] [mailto:[email protected]] On Behalf Of im_sean_s
Sent: Friday, December 02, 2005 1:27 PM
To: [email protected]
Subject: [flexcoders] Custom Validator on CheckBox

 

Hello.  I have a form in an application I'm building that requires the
user to check a CheckBox that acknowledges they read a statement.  In
order to check that the CheckBox has been checked, I created a custom
validator.  The validator works fine, but the problem I have is that
when the user checks the CheckBox, the error message does not go away.
The code for the validator is below.

Thank you,
Sean

class CheckboxRequiredValidator extends mx.validators.Validator
{
           
            public function CheckboxRequiredValidator()
            {
                 
            }
           
            public function doValidation(checkboxValue):Void
            {
           
CheckboxRequiredValidator.validateCheckbox(this,checkboxValue,required,null);
            }
           
            public static function
validateCheckbox(validator:mx.validators.Validator,
                                                                        checkboxValue, required, subfield):Boolean
            {
                  if ( required && !Boolean(checkboxValue))
                  {
                        validator.validationError("notCheckedError", "This checkbox must
be checked.", subfield);
                        return false;
                  }
                  return true;
            }
}
----------------------------------------------------------------------------
<mx:Model id="fieldValues">              
<DonationConfirmation>{DonationConfirmation.selected}</DonationConfirmation>
</mx:Model>

<customValidators:CheckboxRequiredValidator
field="fieldValues.DonationConfirmation" required="true"/>

<mx:CheckBox id="DonationConfirmation" labelPlacement="right"
selected="{formModel.DonationConfirmation}"/>










--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




Reply via email to