Internet - validando emails |
Top Previous Next |
{Basically, you have to make sure the string contains a single at sign ("@") and no white spaces (although, technically speaking, RFC822 allows for white spaces - just don't show them). A semicolon (";") is also considered illegal, since it is used as a separator for multiple addresses.}
s := emailaddy; at := 0; dot := 0; valid := true; for I := 0 to length(s) do begin if (s[I] = '@') then if (at = 0) then at := I else valid := false; if s[I] = '.' then dot := I; end; if not valid or (dot < at+1) then begin MessageDlg('Es wurde keine gültige Sender eMail Adresse angegeben.', mtInformation, [MBOK],0); exit; (* Do whatever you want in this begin ... end block *) end;
// i guess you'd figure out what the vars are =)
(* valid=Bool; at, dot, I = Int; s=String *) |