
02.03.2010, 14:14
|
Местный
|
|
Регистрация: 29.10.2009
Сообщения: 446
Репутация: 271
|
|
Вот простейший вариант.
Код:
function _ValidateChars(const Value:String):Boolean;
var
b:byte;
begin
Result:=false;
for b:=1 to Length(Value) do
if Value[b] in [#65..#122] then
begin
Result:=true;
exit;
end;
end;
function _ValidateNums(const Value:String):Boolean;
var
b:byte;
begin
Result:=false;
for b:=1 to Length(Value) do
if Value[b] in [#48..#57] then
begin
Result:=true;
exit;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
with Edit1 do
if Length(Text) > 5 then
begin
if _ValidateChars(Text) then
begin
if _ValidateNums(Text) then
begin
//Код на выполнение
end
else ShowMessage('В тексте отсутствуют цифры');
end
else ShowMessage('В тексте отсутствуют латинские буквы');
end
else ShowMessage('Длина текста менее 6-ти символов');
end;
|