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

Email validation via javascript in text field

jtbrown3
Registered: Jan 22 2008
Posts: 5

Ted Padova suggested that T Parker has probably written a javascript that validates a text field used to capture email addresses. If that is true where can I get a copy of the script? If not can Tom do this when he is awake?

My Product Information:
Acrobat Pro 8.1.2, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
I don't get the "awake" comment?

Email validation is usually done with a regular expression in the validation event for both AcroForms and LiveCycle Forms.

There are several variations, here's a simple one

var cInput = ...whatever the input is (this.rawValue or event.value) ...
var rgEx = /(\w+\.)*\w+@(\w+\.)+\w+/;
bValid = rgEx.test(cInput);

The regular expression tests groups of word characters separated by "." and a single "@" symbol. You can get much more specific than this, but remember, email addresses can vary quit a bit.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

jtbrown3
Registered: Jan 22 2008
Posts: 5
Sorry about the awake comment. I meant to say that Ted said you probably have thought of this script in your sleep. He claims you dream in code! I will try out the script today and see how it works. I am a complete beginner with JS so it might be dicey for me.