بررسی آدرس ایمیل – دلفی

FUNCTION IsValidEmail(CONST Value: String): boolean;
  FUNCTION CheckAllowed(CONST s: String): boolean;
  VAR i: Integer;
  BEGIN
  Result:= False;
  FOR i:= 1 TO Length(s) DO // illegal char in s -> no valid address
  IF NOT (s[i] IN ['a'..'z','A'..'Z','0'..'9','_','-','.']) THEN Exit;
  Result:= true;
  END;
VAR
  i,len: Integer;
  namePart, serverPart: String;
BEGIN // of IsValidEmail
  Result:= False;
  i:= Pos('@', Value);
  IF (i=0) OR (Pos('..',Value) > 0) THEN Exit;
  namePart:= Copy(Value, 1, i - 1);
  serverPart:= Copy(Value,i+1,Length(Value));
  len:=Length(serverPart);
  // must have dot and at least 3 places from end, 2 places from begin
  IF (len<4) OR
     (Pos('.',serverPart)=0) OR
     (serverPart[1]='.') OR
     (serverPart[len]='.') OR
     (serverPart[len-1]='.') THEN Exit;
  Result:= CheckAllowed(namePart) AND CheckAllowed(serverPart);
END;
//Sample call (put a button1 and a edit1)
procedure TForm1.Button1Click(Sender: TObject);
begin
if IsValidEmail(edit1.Text) = true then
Showmessage('The email is valid')
else
Showmessage('The email is not valid!!');
end;
این نوشته در Delphi ارسال شده است. افزودن پیوند یکتا به علاقه‌مندی‌ها.

35 دیدگاه دربارهٔ «بررسی آدرس ایمیل – دلفی»

  1. Trinity می‌گوید:

    That’s really thinking out of the box. Tnakhs!

  2. Randi می‌گوید:

    Stands back from the keoybard in amazement! Thanks!

  3. Erika می‌گوید:

    helpful task for bringing an item new with the online world!

  4. Guilherme می‌گوید:

    Way to use the internet to help people solve porlbems!

  5. Lovely می‌گوید:

    Help, I’ve been ifnomred and I can’t become ignorant.

دیدگاه‌ها غیرفعال هستند.