You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Hasan Turksoy <ht...@gmail.com> on 2007/02/15 12:32:51 UTC

[validator] locale aware validator scripts required

hi,

i've looked through issues but got no result...

does anybody has locale related issues about validator javascripts?
when the locale is EN: thousand seperator="," ,  decimal seperator='.'
(like: 123,45.67)
 when the locale is TR(my case): thousand seperator="." ,  decimal
seperator=',' (like: 123.45,67)

as far as i can see, validator javascripts written for EN locale in mind..
so, validator scripts are not working properly for my situation...

for example, for the above value, validateFloat will split my number after
123..

as a workaround solution; i changed ValidatorScript.java(of shale.jar).. it
assigns current locale's decimal and thousand seperator into two global
javascript variables..
resolting code is like below:
var localeSpecificThousandSeperator = '.';
var localeSpecificDecimalSeperator = ',';

and validators those want to validate seperator related values can use these
variables...

example validateFloat implementation code will then be like:
var tempArray = value.split(*localeSpecificDecimalSeperator*);
instead of
 var tempArray = value.split(*'.'*);

are there any other solutions exist? other suggestions? or can i use some
attributes of commons-validator components to overcome this issue..?

regards..

hasan

Re: [validator] locale aware validator scripts required

Posted by Niall Pemberton <ni...@gmail.com>.
On 2/15/07, Hasan Turksoy <ht...@gmail.com> wrote:
> hi,
>
> i've looked through issues but got no result...
>
> does anybody has locale related issues about validator javascripts?
> when the locale is EN: thousand seperator="," ,  decimal seperator='.'
> (like: 123,45.67)
>  when the locale is TR(my case): thousand seperator="." ,  decimal
> seperator=',' (like: 123.45,67)
>
> as far as i can see, validator javascripts written for EN locale in mind..
> so, validator scripts are not working properly for my situation...
>
> for example, for the above value, validateFloat will split my number after
> 123..
>
> as a workaround solution; i changed ValidatorScript.java(of shale.jar).. it
> assigns current locale's decimal and thousand seperator into two global
> javascript variables..
> resolting code is like below:
> var localeSpecificThousandSeperator = '.';
> var localeSpecificDecimalSeperator = ',';
>
> and validators those want to validate seperator related values can use these
> variables...
>
> example validateFloat implementation code will then be like:
> var tempArray = value.split(*localeSpecificDecimalSeperator*);
> instead of
>  var tempArray = value.split(*'.'*);
>
> are there any other solutions exist? other suggestions? or can i use some
> attributes of commons-validator components to overcome this issue..?

Unfortunately there isn't a solution in Commons Validator for this -
the JavaScript implementations are not Locale aware. Its something
that would be good to do - the best way to keep it on the radar is to
file a Jira ticket for it:

http://jakarta.apache.org/commons/validator/issue-tracking.html

Niall

> regards..
>
> hasan

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org