These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Creating an Email Address Format to the text box Formatting

Grumlin3
Registered: Dec 5 2007
Posts: 12

I am trying to create a form that requires a person Email Address, I was wondering what I have to do to the text box format in order for it to require an Email format i.e. poakes [at] regis [dot] edu. If a student doesn't enter in the correct format it will let them know.

I work for Regis University working on a Masters.

My Product Information:
Acrobat Pro 7.0.0, Windows
pddesigner
Registered: Jul 9 2006
Posts: 858
Right click the Text field for the Email address entry. Click Properties from the drop down list. Click the Validate tab, find the Run Custom Validation script then click the edit button. Paste this code in the box and close.

var re = /^\S+@\S+\.\w{3}$/
var re2 = /^\w+([-_]\w+)*@\w+(\.\w{2,3})+$/

if (re.test(event.value) == false) {
app.alert("\"" + event.value + "\" is not a valid email address.")
app.beep()
}Note: Make this field and the following Name field required fields.

var re = /^[A-Z][a-z]+ [A-Z][a-z]+$/

if (re.test(event.value) == false) {
app.alert("That does not appear to be a valid name. I need a first and last name.")
app.beep()
}

My favorite quote - "Success is the ability to go from one failure to another with no loss of enthusiasm.

Spanners
Registered: May 21 2008
Posts: 1
The above code works, but only for emails with a format name [at] domain [dot] comIt doesn't work for an email such as name [dot] surname [at] domain [dot] com [dot] au
It beeps as if it is invalid.

What code do I need to add/change in order to get it to allow more formats of emails?
Tigerlady
Registered: Oct 31 2006
Posts: 20
Spanners asked a question about futher validation for emails like
name [dot] surname [at] domain [dot] com [dot] auis there any validation code like this?

thanks.

Have to have this done by Monday.

Ms. Barbara S. ONeal
President/Co-Founder
Centric Web®, Inc.
630-734-0741
http://www.centricweb.com
Adobe Community Expert

Merlin
Acrobat 9ExpertTeam
Registered: Mar 1 2006
Posts: 766
This code will do the trick :

var alert1 = ("Type your alert text here"); var email = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;if(!email.test(event.value)){event.rc = false;app.alert(alert1);event.value = "example\u0040example.com";}

;-)
Bengt
Registered: Feb 2 2009
Posts: 7
Merlin
Maybe you also can solve my problem. I have pdf with some hundred e-mail addresses in a column in both format name [at] company [dot] domain .and name [dot] name [at] company [dot] domain.The document is imported to Adobe 7 Standard as a .pdf-file.

When I use the command Create links from URL-addresses in the document under the menu Advanced, it is just the name to the left on @ is shown in the URL-address not name.name.

I I have an address with a number of dots but not any @ it works fine as www.name.name.name.name
Do you have a script also for this problem?
Tim Anderson
Registered: Feb 21 2009
Posts: 2
Merlin wrote:
This code will do the trick :
var alert1 = ("Type your alert text here"); var email = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;if(!email.test(event.value)){event.rc = false;app.alert(alert1);event.value = "example\u0040example.com";}

;-)
Hello Merlin,
I used your code above for email validation in Acrobat Pro 9 and it works beautifully!

However, I am using it in a saveable fillin form and, after saving an email address in the form, Acrobat Reader will not let me (or anyone else potentially filling out the form) clear the email text field. Do you know of any way to change the code above to make it possible to clear the email text field after having saved it? Sure would appreciate your help if possible. Thanks!

Tim
itwmecheng
Registered: Oct 4 2007
Posts: 10
I was trying to accomplish the same thing, Tim, when I came across these examples. Here is how I solved the problem using a combination of Merlin's code and pddesigner's code:

var email = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/; if (event.value!=""){if (!email.test(event.value)){event.rc = false;app.alert("\"" + event.value + "\" is not a valid email address.");};};
Tim Anderson
Registered: Feb 21 2009
Posts: 2
itwmecheng wrote:
I was trying to accomplish the same thing, Tim, when I came across these examples. Here is how I solved the problem using a combination of Merlin's code and pddesigner's code:
var email = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/; if (event.value!=""){if (!email.test(event.value)){event.rc = false;app.alert("\"" + event.value + "\" is not a valid email address.");};};
Works great....Thanks, itwmecheng!