Skip navigation
Currently Being Moderated

Company email address

May 18, 2012 11:10 AM

Tags: #reader #acrobat_10_pro

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:

*@companyname.com

 

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.

 
Replies
  • George Johnson
    9,208 posts
    Aug 11, 2002
    Currently Being Moderated
    May 18, 2012 1:59 PM   in reply to 01371406

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

     

    })();

     
    |
    Mark as:
  • George Johnson
    9,208 posts
    Aug 11, 2002
    Currently Being Moderated
    May 21, 2012 10:36 AM   in reply to 01371406

    You don't have to change anything apart from the sDomain variable and the text of the error message you want to use. It will work with any field name, just place the entire script in the Validate event of the field.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points