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>
|