Highlighted
WangXiaolong Trusted Contributor.
Trusted Contributor.
297 views

(SM) Support Tip : How to validate Email address in contact table

How to validate Email address in contact table

Scenario:
The email address can be save with an invalid format when add/update contact table.
Workaround:
1. In ScriptLibrary and Search: StringUtil
2. Add new function at the end of this file:
function ValidateEmail(emailAddr)
{
var mailformat = /?\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
if (emailAddr.match(mailformat)) {
return true;
} else {
return false;
}
}
3. In format control file: contacts >> validations
Add new validation:
Validation: jscall("StringUtil.ValidateEmail", email in $file)
Message: Email Address is not valid.
Add: true
Update: true
Set Focus to: email

Labels (1)
1 Reply
a2drew Honored Contributor.
Honored Contributor.

Re: (SM) Support Tip : How to validate Email address in contact table

the mail format variable caused errors for me when I tried to complie it so I modified it to:

var mailformat=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.