1
2 unit Unit1;
3
4 interface
5
6 uses
7 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
8 Dialogs, StdCtrls;
9
10 type
11 TForm1 = class(TForm)
12 Button1: TButton;
13 Edit1: TEdit;
14 procedure Button1Click(Sender: TObject);
15 private
16 { Private declarations }
17 public
18 procedure ValidEmail(sEmail:string);
19 { Public declarations }
20 end;
21
22 var
23 Form1: TForm1;
24
25 implementation
26
27 {$R *.dfm}
28
29 procedure TForm1.Button1Click(Sender: TObject);
30 begin
31 ValidEmail(Edit1.text);
32 end;
33
34 procedure TForm1.ValidEmail(sEmail: string);
35 var
36 at,dot,i:Integer;
37 bOkay:boolean;
38 sline:string;
39 begin
40
41 at:=Pos('@',sEmail);
42 dot :=LastDelimiter('.',sEmail);
43 bOkay:=(at>0)and(dot>at);
44
45
46 if bOkay then begin
47 for i:=1 to Length(sEmail) do begin
48 if not (sEmail[i] in ['a'..'z','A'..'Z','0'..'9','-','_','.','@']) then begin
49 bOkay:=false;
50 break;
51 end;
52
53 end
54 end;
55
56 if not bOkay then
57 Showmessage('Not a valid Email address')
58 else
59 ShowMessage('Valid Address');
60 end;
61
62 end.
|