Loading ...
Sorry, an error occurred while loading the content.

Re: Email address validation

Expand Messages
  • _eclipsed_
    ... do ... Try this out: procedure TContactInfoForm.EmailEditKeyPress(Sender: TObject; var Key: Char); { Only allows valid email address characters } const
    Message 1 of 2 , Jan 31, 2002
    • 0 Attachment
      --- In tmail2000@y..., "nlhassociates" <roy.lambert@n...> wrote:
      > I need to check if an email address is in the valid format. I'm
      > feeling lazy and wonder if anyone has already written the code to
      do
      > it. If so could I please have a copy.
      >
      > TIA
      >
      > Roy

      Try this out:
      procedure TContactInfoForm.EmailEditKeyPress(Sender: TObject;
      var Key: Char);
      { Only allows valid email address characters }
      const
      AllowedChars: string = 'abcdefghijklmnopq' +
      'rstuvwxyz0123456789_.@';
      var
      i: Integer;
      Ok: Boolean;
      begin
      i := 0;
      Ok := False;
      {If you erase next line, user won't be able to type backspace}
      if Key = #8 then
      Ok := True;
      repeat
      i := i + 1;
      if Key = AllowedChars[i] then
      Ok := True;
      until (Ok) or (i = Length(AllowedChars));
      if not Ok then
      Key := #0;
      end;
      -Adam
    Your message has been successfully submitted and would be delivered to recipients shortly.