- function TestMail(EMail:string):boolean;
- var
- a,b,c:integer;
- TmpS,accept:string;
- begin
-
-
- TmpS := lowercase(EMail);
- Result := True;
- accept := 'abcdefghijklmnopqrstuvwxyz0123456789-@._~'; //caractères acceptés
-
- //test caractères non acceptés
- for a:=1 to length(TmpS) do begin //Pour chaque caractère de l'e-mail
- c:=0;
- for b:=1 to length(accept) do //si il est pas dans la liste des acceptés
- if copy(TmpS,a,1) = copy(accept,b,1) then c:=1;
- if c=0 then Result :=false; //c pas bon
- end;
-
- //test compte '@' = 1
- b:=0;
- for a:=1 to length(TmpS) do //pour tous les caractères
- if copy(TmpS,a,1) = '@' then b:=b+1; //si il trouve @ il ajoute 1
- if b <> 1 then Result := False; //comme il faut un seul @,
- //si il en trouve plusieurs c pas bon
- //test compte '.' = 0
- if pos('.',TmpS) = 0 then Result := false; //si ya 0 '.' dans l'email c pas bon
-
- end;
function TestMail(EMail:string):boolean;
var
a,b,c:integer;
TmpS,accept:string;
begin
TmpS := lowercase(EMail);
Result := True;
accept := 'abcdefghijklmnopqrstuvwxyz0123456789-@._~'; //caractères acceptés
//test caractères non acceptés
for a:=1 to length(TmpS) do begin //Pour chaque caractère de l'e-mail
c:=0;
for b:=1 to length(accept) do //si il est pas dans la liste des acceptés
if copy(TmpS,a,1) = copy(accept,b,1) then c:=1;
if c=0 then Result :=false; //c pas bon
end;
//test compte '@' = 1
b:=0;
for a:=1 to length(TmpS) do //pour tous les caractères
if copy(TmpS,a,1) = '@' then b:=b+1; //si il trouve @ il ajoute 1
if b <> 1 then Result := False; //comme il faut un seul @,
//si il en trouve plusieurs c pas bon
//test compte '.' = 0
if pos('.',TmpS) = 0 then Result := false; //si ya 0 '.' dans l'email c pas bon
end;