how to check email and website entered
how to check email and website entered
Please members get me codes for my data entry to check email and website entered is correct else display an error message.
-
- Posts: 1796
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: how to check email and website entered
Some tasks like this might be easier if CSPro had a way to evaluate regular expressions, but such functionality doesn't exist in the current version of CSPro. You could write logic to evaluate email addresses. This might allow some invalid email addresses through, but it would work for 99% of email addresses (except that it doesn't evaluate the final domain). Here is sample logic for the email address:
PROC EMAIL
numeric isValid = 1;
numeric atPos1 = pos("@",EMAIL);
numeric atPos2 = pos("@",EMAIL[atPos1 + 1]);
if atPos1 = 0 or atPos2 > 0 then // there must be only one @
isValid = 0;
elseif atPos1 < 2 or ( length(strip(EMAIL)) - atPos1 ) = 0 then // there must be at least one character on both sides of the @
isValid = 0;
elseif pos(".",EMAIL[atPos1 + 1]) = 0 then // there must be a . after the @
isValid = 0;
else
numeric ctr;
do ctr = 1 while ctr <= length(strip(EMAIL)) and isValid
if ctr <> atPos1 and poschar("ABCDEFGHIJKLMNOPQRSTUVWXYZ.",toupper(EMAIL[ctr:1])) = 0 then
isValid = 0;
endif;
enddo;
endif;
if not isValid then
errmsg("Error in the email address: %s",strip(EMAIL));
reenter;
endif;
numeric isValid = 1;
numeric atPos1 = pos("@",EMAIL);
numeric atPos2 = pos("@",EMAIL[atPos1 + 1]);
if atPos1 = 0 or atPos2 > 0 then // there must be only one @
isValid = 0;
elseif atPos1 < 2 or ( length(strip(EMAIL)) - atPos1 ) = 0 then // there must be at least one character on both sides of the @
isValid = 0;
elseif pos(".",EMAIL[atPos1 + 1]) = 0 then // there must be a . after the @
isValid = 0;
else
numeric ctr;
do ctr = 1 while ctr <= length(strip(EMAIL)) and isValid
if ctr <> atPos1 and poschar("ABCDEFGHIJKLMNOPQRSTUVWXYZ.",toupper(EMAIL[ctr:1])) = 0 then
isValid = 0;
endif;
enddo;
endif;
if not isValid then
errmsg("Error in the email address: %s",strip(EMAIL));
reenter;
endif;