• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 212
  • Last Modified:

how to use alphabetical EditMask?

i want to only allow users to input characters of the alphabet in a TEdit

from the help file, it says

"The L character requires an alphabetic character only in this position"

so i put 'LLLLL' for the EditMask
but now the edit only allows the character L...
is there something missing?

i don't quite understand the usage of '!' and '\'.
am i supposed to put one of those infront of each 'L' ?

there's no example for alphabetical EditMasks in Help.

thanks in advance.


ViV
0
sohmuijai
Asked:
sohmuijai
  • 2
  • 2
  • 2
  • +1
1 Solution
 
Slick812Commented:
hello sohmuijai, you might put this code in your edit's OnKeyPress Event

procedure TForm1.Edit4KeyPress(Sender: TObject; var Key: Char);
begin
if Ord(Key) = 8 then Exit;
if (Ord(Key) < Ord('a')) or (Ord(Key) > Ord('z')) then
if (Ord(Key) < Ord('A')) or (Ord(Key) > Ord('Z')) then
Key := #0;
end;
0
 
Slick812Commented:
that's for a Regular TEdit, , , NOT a MaskEdit
0
 
Lukasz LachCommented:
procedure TForm1.MaskEdit1KeyPress(Sender: TObject; var Key: Char);
begin
  if Ord(Key) = 8 then Exit else
  if Key in ['A'..'Z', 'a'..'z'] then Key := #0;
end;

That's rather more clear, isn't it? ;-)
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
sohmuijaiAuthor Commented:
hmm..
but i would like to use the EditMask property...

maybe i should also tell u that i need the input as
'num num P E/U/C num num num num num num'
eg. '03PE123456'

right now, i put EditMask as '00PL000000'
i can correctly check input until '03P'
but the 4th character is only accepting 'L'..
which i do not want...


ViV
0
 
Lukasz LachCommented:
it should be:

procedure TForm1.MaskEdit1KeyPress(Sender: TObject; var Key: Char);
begin
 if Ord(Key) = 8 then Exit else
 if not (Key in ['A'..'Z', 'a'..'z']) then Key := #0;
end;

sorry =)
0
 
geobulCommented:
Hi,

Your mask works well on my computer. Try that mask in a form without any additional code. Create a new project, add one TMaskEdit and set its EditMask property to '00PL000000'. Run the project and test the mask.

I suppose that there is code written by you which interferes with the mask.

Regards, Geo
0
 
sohmuijaiAuthor Commented:
hmm... does it have to be a TMaskEdit?

i'm using a derived TEdit called TZEdit by some other person that also has the EditMask property...
maybe the derivation wasn't very good.....

thanks
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now