Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread Simple TEdit show/validate input?
Fri, Sep 13 2013 9:43 PMPermanent Link

Ralf Bertoldi

How can I validate/show the input of an TEdit?

Is there any display or edit mask?

I need to edit/show integer and currency values. There is no database
attached.

For example just 2x TEdit's , one for integer (0-9), one for currency (0.00).

How can I avoid false input?
What would be the best way to show the values if there would be a display mask?

TIA

ralf
Fri, Sep 13 2013 11:42 PMPermanent Link

Raul

Team Elevate Team Elevate

Ralf,

Haven't had to use it myself but one idea is to handle this in the
OnKeyPress or OnKeyDown event. Something like this in OnKeyPress:

if Key >= '0' and Key <= '9' then
  result := true
else
  result := false;

you can obviously check for length and such as well if you want to allow
only certain length numbers.

Currency is bit trickier as you'd likely want to allow only one "." and
only after numbers and otherwise just numbers but quite doable.

For masking you might have to do something like use "_.__" mask and then
handle keydown or keypress, return false and actually update the edit
control value in code (replacing the _ with the value) though this
becomes bit more pain to manage.


Raul


On 9/13/2013 9:43 PM, Ralf Bertoldi wrote:
> How can I validate/show the input of an TEdit?
>
> Is there any display or edit mask?
>
> I need to edit/show integer and currency values. There is no database
> attached.
>
> For example just 2x TEdit's , one for integer (0-9), one for currency (0.00).
>
> How can I avoid false input?
> What would be the best way to show the values if there would be a display mask?
>
> TIA
>
> ralf
>
Sun, Sep 15 2013 6:45 PMPermanent Link

Ralf Bertoldi

Raul,

Many thanks for your answer.!
I was not sure if there are any functions/properties for that.
I'll try to solve that in a native way; manual lacks on this.

..  at the moment I'm trying to find all the workarounds for the js bugs in EWB..
.. really hard work.. Smile

thanks,

Ralf

Raul wrote:

Ralf,

Haven't had to use it myself but one idea is to handle this in the
OnKeyPress or OnKeyDown event. Something like this in OnKeyPress:

if Key >= '0' and Key <= '9' then
  result := true
else
  result := false;

you can obviously check for length and such as well if you want to allow
only certain length numbers.

Currency is bit trickier as you'd likely want to allow only one "." and
only after numbers and otherwise just numbers but quite doable.

For masking you might have to do something like use "_.__" mask and then
handle keydown or keypress, return false and actually update the edit
control value in code (replacing the _ with the value) though this
becomes bit more pain to manage.


Raul


On 9/13/2013 9:43 PM, Ralf Bertoldi wrote:
> How can I validate/show the input of an TEdit?
>
> Is there any display or edit mask?
>
> I need to edit/show integer and currency values. There is no database
> attached.
>
> For example just 2x TEdit's , one for integer (0-9), one for currency (0.00).
>
> How can I avoid false input?
> What would be the best way to show the values if there would be a display mask?
>
> TIA
>
> ralf
>
Tue, Sep 17 2013 1:41 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Ralf,

<< .  at the moment I'm trying to find all the workarounds for the js bugs
in EWB.. . really hard work.. Smile>>

What JS bugs are you referring to ?

Tim Young
Elevate Software
www.elevatesoft.com
Image