FUNCTION ValidateEmail LPARAMETERS cEmail LOCAL llResult && holds correction status so far LOCAL llFirst && we are at the beginning of a part LOCAL llAt && a @ is present LOCAL llPoint && the last char scanned was a point? LOCAL lnLoop STORE .T. TO llResult, llFirst STORE .F. TO llAt, llPoint FOR lnLoop = 1 TO LEN(cEmail) lcChar = SUBSTR(cEmail,lnLoop,1) IF lcChar = '.' IF llFirst OR llPoint llResult = .F. && can't start with point or repeat it in sequence ELSE llPoint = .T. ENDIF ELSE DO CASE CASE lcChar = '@' IF llFirst OR llAt OR llPoint llResult = .F. && can't start with @ or repeat it ELSE STORE .T. TO llFirst, llAt && domain name starts llPoint = .F. ENDIF CASE BITAND(ASC(lcChar),0x80)!=0 llResult = .F. && non-ASCII is forbidden CASE AT(lcChar,' ()<>,;:\"[]')!=0 llResult = .F. && and so are reserved characters CASE lcChar<' ' OR lcChar = CHR(0x7f) llResult = .F. && and control characters OTHERWISE STORE .F. TO llFirst, llPoint ENDCASE ENDIF IF !llResult EXIT ENDIF ENDFOR llResult = llResult AND llAt AND !llPoint AND !llFirst RETURN llResult ENDDEF FUNCTIONbye