realbasic-nug
[Top] [All Lists]

Re: email validating editfield

To: REALbasic NUG <realbasic-nug@lists.realsoftware.com>
Subject: Re: email validating editfield
From: Jerry Fritschle <jerryfritschle@mac.com>
Date: Wed, 25 Feb 2009 23:46:38 -0600
Authentication-results: mx.google.com; spf=neutral (google.com: 74.124.194.228 is neither permitted nor denied by best guess record for domain of realbasic-nug-bounces@lists.realsoftware.com) smtp.mail=realbasic-nug-bounces@lists.realsoftware.com
Delivered-to: listarchive@realsoftware.com
In-reply-to: <A899E015-A7B2-413F-9F3C-0C5BDBFE4A6D@torchpublishing.com.au>
References: <A899E015-A7B2-413F-9F3C-0C5BDBFE4A6D@torchpublishing.com.au>
Reply-to: REALbasic NUG <realbasic-nug@lists.realsoftware.com>
Sender: realbasic-nug-bounces@lists.realsoftware.com

On Feb 25, 2009, at 8:11 PM, Kim Kohen wrote:

Does anyone happen to have or know of, an open source email validation editfield class?

If you're speaking of simply validating the construction of the address (and not whether it really exists), this should more or less work. For testing, I put it in the editfield's LostFocus event.

  dim validEmailAddress as Boolean
  dim Position as integer
  dim field as string


  if me.text<>"" then//well, obviously, can't be a blank string.

    if instr(me.text,chr(32))=0 then//no spaces in it

      Position=instr(me.text,"@")

if Position>1 then//there is an "@" with at least one character in front of it.

        if instr(Position+1,me.text,"@")=0 then//that was the ONLY "@"

//look for dot suffix(es) now. I'm looking for one or more suffixes that
          //have at least two characters, but no more than four.
          //Tweak if you know the rules better.


          Position=CountFields(me.text,".")

for x as Integer=2 to Position//we're ignoring anything in front of the first dot.

            field=NthField(me.text,".",x)

            validEmailAddress=(len(field)>1 and len(field)<5)

          next
        end if

      end if

//I have not allowed for an IP address after the "@". Does anyone really do that?

    end if


  end if
  if not validEmailAddress then
    MsgBox "This does not appear to be a valid address."

  end if




-----
"Drama is life with the dull bits cut out."
-Alfred Hitchcock

Jerry Fritschle
jerryfritschle@mac.com



_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>