Tuesday, August 10, 2010

email field validation

public boolean validateField(fieldId _fieldIdToCheck)
{
boolean ret;
str email;
;

ret = super(_fieldIdToCheck);

if (_fieldIdToCheck == fieldnum(WRPartyApplDetails, NewEmail))
{
email = this.Email;

if ( strfind(email, "@", 1, strlen(email)) == 0
|| strfind(email, ".", 1, strlen(email)) == 0)
{
error("Must contain a '@' character and at least one '.'");
ret = false;
}

if ( strscan(email, ".@", 1,strlen(email)) > 0
|| strscan(email, "@.", 1,strlen(email)) > 0)
{
error("Cannot have the '@' and the '.' one after the other");
ret = false;
}
}

return ret;
}