You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pivot.apache.org by Sandro Martini <sa...@gmail.com> on 2009/06/23 15:42:56 UTC

Text Input: Mask input chars

Hi to all,
for Text Inputs, there is a simple way to set a Mask pattern (String),
with only accepted chars to display (and reject others) ?
This should happen at any key press or paste event inside Text Inputs
and Text Area (and maybe other components where the user manually set
values).

A general way could be to set a pattern string (like in NumberFormat
etc), or better with a regexp, but maybe in this case could be too
much heavy (computational) ... this could be a great companion for all
data input applications.

Validators make a thing like this, but without blocking the char to be
displayed.

Suggestions, ideas, things missing ?

Thanks,
Sandro

Re: Text Input: Mask input chars

Posted by Sandro Martini <sa...@gmail.com>.
Ok, it will be useful to many others ...

Thanks.

Re: Text Input: Mask input chars

Posted by Greg Brown <gk...@mac.com>.
Ideally, we'll add a section on text validation to the tutorial, and  
an example such as this could go there.

On Jun 25, 2009, at 9:42 AM, Sandro Martini wrote:

> Hi Greg,
> I've tried what you suggested me and (as usual) all works good, many  
> thanks !!
>
>
> What do you think to add this portion of code (for example) inside the
> TextInputValidatorTest class (i think many users expect a feature like
> this, and could search in this class ...) ?
>
> // the following line of code already exist in the source
>        textinputFloatRange.setValidator(new  
> FloatRangeValidator(0.3f, 2000f));
>
> // TODO: new code, to add
>        // optional, force a TextInput with strict currency validation
>        // (with this enabled, wrong chars will not be accepted nor  
> displayed)
>        textinputFloatRange.getStyles().put("strictValidation", true);
>
>
> Thanks,
> Sandro


Re: Text Input: Mask input chars

Posted by Sandro Martini <sa...@gmail.com>.
Hi Greg,
I've tried what you suggested me and (as usual) all works good, many thanks !!


What do you think to add this portion of code (for example) inside the
TextInputValidatorTest class (i think many users expect a feature like
this, and could search in this class ...) ?

// the following line of code already exist in the source
        textinputFloatRange.setValidator(new FloatRangeValidator(0.3f, 2000f));

// TODO: new code, to add
        // optional, force a TextInput with strict currency validation
        // (with this enabled, wrong chars will not be accepted nor displayed)
        textinputFloatRange.getStyles().put("strictValidation", true);


Thanks,
Sandro

Re: Text Input: Mask input chars

Posted by Sandro Martini <sa...@gmail.com>.
Ok, I'll try and tell something ... but if all works good in this way
(as should be :-) ), what do you think on put a snippet of this also
in the Form Demo, or at least in the TextInputValidatorTest ? Could
help others to do the same thing ...

Thanks for the moment,
Sandro

Re: Text Input: Mask input chars

Posted by Greg Brown <gk...@mac.com>.
Try using a validator with the strictValidation style of the TextInput  
set to true.

On Jun 23, 2009, at 9:42 AM, Sandro Martini wrote:

> Hi to all,
> for Text Inputs, there is a simple way to set a Mask pattern (String),
> with only accepted chars to display (and reject others) ?
> This should happen at any key press or paste event inside Text Inputs
> and Text Area (and maybe other components where the user manually set
> values).
>
> A general way could be to set a pattern string (like in NumberFormat
> etc), or better with a regexp, but maybe in this case could be too
> much heavy (computational) ... this could be a great companion for all
> data input applications.
>
> Validators make a thing like this, but without blocking the char to be
> displayed.
>
> Suggestions, ideas, things missing ?
>
> Thanks,
> Sandro