I need to verify an entered email address on a PDF is a company only email address inputed. No gmail, yahoo or other types of email address should be accepted.
For example I need the only valid email addresses to be accepted:
Should I use a truncate function to compare values or is there a better way to validate this field? To clarify I don't care if the email address is a valid company email address. Just so that it ends with @companyname.com
Thanks.
A custom Validate script for the field could look like:
// Custom Validate script
(function () {
var sDomain = "example.com";
// Don't do anything if field is blank
if (!event.value) return;
// Get the domain of the entered address, if any
var sEnteredDomain = event.value.split("@")[1];
if (typeof sEnteredDomain === "undefined" || sEnteredDomain.toLowerCase() !== sDomain) {
// Reject the entry
event.rc = false;
// Alert the user
app.alert("Please enter a valid email address.\r\rDomain must be: " + sDomain, 3);
}
})();
Thanks George. I am having some problem translating this code into my PDF. I am new to programing javascript and in Acrobat. I don't understand where my field name ("Email") goes to account for the field haivng the script validate the email. I thought substituting the word Email for !event and later on in the code Email for event would suffice. That is not working however. Any suggestions? Thanks for your response.
North America
Europe, Middle East and Africa
Asia Pacific