Valdating Email Address
Posted: Mon Apr 16, 2007 8:41 pm
by swarovski
I have put a Email Address textbox in the Registration Information screen for my setup project.
How do I validate it?
Simple rules like
someone@company.com is enough.
must have @ and .
Thank you!
Posted: Tue Apr 17, 2007 10:32 am
by Fig
This is a bit simplistic (doesn't check for invalid characters) but try:
Set Variable EMAILFAIL to TRUE
Set Variable EMAILNAME to
Set Variable EMAILDOMAIN to
Comment: Check for invalid space character (pattern in next statement is a space)
Parse String $EMAIL$ into Variables EMAILNAME and EMAILDOMAIN (Split at first occurrence of pattern)
if Variable EMAILDOMAIN Equals
Comment: Check for strings on each side of the asterisk (pattern in next Parse String is an asterisk)
Parse String $EMAIL$ into Variables EMAILNAME and EMAILDOMAIN (Split at first occurrence of pattern)
if Variable EMAILNAME not Equals
if Variable EMAILDOMAIN not Equals
Comment: Check for a period in the domain (pattern in next Parse String is a period)
Set Variable EMAILDOMAIN_1 to
Set Variable EMAILDOMAIN_2 to
Parse String $EMAILDOMAIN$ into Variables EMAILDOMAIN_1 and EMAILDOMAIN_2 (Split at last occurrence of pattern)
if Variable EMAILDOMAIN_1 not Equals
if Variable EMAILDOMAIN_2 not Equals
Set Variable EMAILFAIL to FALSE
end
end
end
end
end
if Variable EMAILFAIL Equals True
Comment: Take action on the invalid e-mail address
end
Where $EMAIL$ is the variable containing the email address to test.
Posted: Sun Jun 10, 2007 11:05 pm
by swarovski
Thanks a lot Fig. It really helps!
btw, the pattern in the 2nd parse should be: "@"
Fig wrote:This is a bit simplistic (doesn't check for invalid characters) but try:
Set Variable EMAILFAIL to TRUE
Set Variable EMAILNAME to
Set Variable EMAILDOMAIN to
Comment: Check for invalid space character (pattern in next statement is a space)
Parse String $EMAIL$ into Variables EMAILNAME and EMAILDOMAIN (Split at first occurrence of pattern)
if Variable EMAILDOMAIN Equals
Comment: Check for strings on each side of the asterisk (pattern in next Parse String is an asterisk)
Parse String $EMAIL$ into Variables EMAILNAME and EMAILDOMAIN (Split at first occurrence of pattern)
if Variable EMAILNAME not Equals
if Variable EMAILDOMAIN not Equals
Comment: Check for a period in the domain (pattern in next Parse String is a period)
Set Variable EMAILDOMAIN_1 to
Set Variable EMAILDOMAIN_2 to
Parse String $EMAILDOMAIN$ into Variables EMAILDOMAIN_1 and EMAILDOMAIN_2 (Split at last occurrence of pattern)
if Variable EMAILDOMAIN_1 not Equals
if Variable EMAILDOMAIN_2 not Equals
Set Variable EMAILFAIL to FALSE
end
end
end
end
end
if Variable EMAILFAIL Equals True
Comment: Take action on the invalid e-mail address
end
Where $EMAIL$ is the variable containing the email address to test.