Oops, this is the problem I was trying to answer to. Sorry folks about the
previous post... :)

Class MyDateValidator extends mx.validators.DateValidator
{
    public function validationError(errorCode:String,
defaultMessage:String,subfield:String):Void
    {
       If (errorCode == “wrongLength”)
         defaultMessage = yourTranslatedMessage;

       super.validationError(errorCode, defaultMessage, subfield);
    }
}

Only thing you need to do is catch the wrongLength error and re-write the
error message yourself.

-Mika

-----Original Message-----
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Kai König
Sent: 17. elokuuta 2005 16:56
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Changing the wrongLengthError in a DateValidator

Hi all,

another validator-related question:

Having to validate for a date using a DateValidator, the requirements
are to just deliver one validation message if the validation fails.
Following the concept, I'd have to add a long list of attributes to my
validator call, as in:

<mx:DateValidator ... invalidCharError="blabla"
                      invalidFormatCharsError="blabla" ... />

So we thought it might be nice to subclass the DataValidator and to
define a defaultErrorMessage which we can pass into our own validator
class and internally, the class is responsible to overwrite the values
of the pre-defined errors.

Works quite good, BUT doesn't work for wrongLengthError. The docs
state:

>Error message when the length of the date doesn't match that of the
>inputFormat. Default is "Please type the date in the format
><i>inputFormat</i>.".

That means the default error might be something like:
"Please...format mm/dd/yyyy"

As far as I understand, I'd expect to be able to overwrite the default
with anything I like, but regardless to what I set the value for
wrongLengthError, Flex always adds the value of inputFormat to my
error message - I end up with something like

"This is my errortext and I want you to type it correct mm/dd/yyyy"

This is especially annoying with localized error messages in which the
inputFormat has to be at another place within the error message by
grammar: "Bitte nutzen Sie das Format dd.mm.yyyy in diesem Feld".

Is there a way to get rid of the automatic concatenation of the
inputFormat within the wrongLengthError of this validator?

Cheers
Kai









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



 






------------------------ Yahoo! Groups Sponsor --------------------~--> 
<font face=arial size=-1><a 
href="http://us.ard.yahoo.com/SIG=12het67b5/M=362329.6886308.7839368.1510227/D=groups/S=1705007207:TM/Y=YAHOO/EXP=1124367794/A=2894321/R=0/SIG=11dvsfulr/*http://youthnoise.com/page.php?page_id=1992
">Fair play? Video games influencing politics. Click and talk back!</a>.</font>
--------------------------------------------------------------------~-> 

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

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to