Interview Questions

Wednesday, May 14, 2014

Email validation in ax

write  validateField in table methods-

NewEmail is Edt(String Type)

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

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

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

No comments:

Post a Comment