
24.03.2010, 21:52
|
 |
Администратор
|
|
Регистрация: 03.10.2005
Адрес: Россия, Москва
Сообщения: 1,553
Версия Delphi: Delphi 7
Репутация: выкл
|
|
Код:
function CheckAllowed(const s:string):boolean;
var
i: integer;
begin
Result:= false;
for i:= 1 to Length(s) do
begin
if not (s[i] in ['a'..'z', 'A'..'Z', '0'..'9', '_', '-', '.']) then
Exit;
end;
Result:= true;
end;
function IsValidEmail(const Value:string):boolean;
var
i: integer;
namePart, serverPart: string;
begin
Result:= false;
i:= Pos('@', Value);
if i = 0 then
Exit;
namePart:= Copy(Value, 1, i - 1);
serverPart:= Copy(Value, i + 1, Length(Value));
if (Length(namePart) = 0) or ((Length(serverPart) < 5)) then
Exit;
i:= Pos('.', serverPart);
if (i = 0) or (i > (Length(serverPart) - 2)) then
Exit;
Result:= CheckAllowed(namePart) and CheckAllowed(serverPart);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if not IsValidEmail(Edit2.Text)
then ShowMessage('email неправильный')
else button7.Click;
end;
|