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

LiveCycle Designer - Validating Email address

gombear
Registered: Oct 6 2011
Posts: 18
Answered

Hi,
I have email address field in the form.
I tried using "Email - alphanumeric" pattern (text{OOOOOOOO' [at] example [dot] com'}
) under validation tab. But it is not working.
It takes just name without @.
Also after @, it would not take 2 dots such as dept.county.org asvalid email address.
 
I guess I need a script to validate the field.
Could someone show me how to do this for Adobe LiveCycle Designer.
Thanks,
Gombear

My Product Information:
LiveCycle Designer, Windows
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Accepted Answer
Hi,

for those validations you should use regular expressions.
This script in the exit:Event checks the entered mail addresses (RFC 2822).
  1. var RegExpMail = /([A-Za-z0-9\!\#\$\%\&\'\*\+\-\/\=\?\^\_\`\{\}\|\~]+|"([\x01-\x08\x0B\x0C\x0E-\x1F\x21\x23-\x5B\x5D-\x7F]|\\[\x0-\x7F])*")(\.([A-Za-z0-9\!\#\$\%\&\'\*\+\-\/\=\?\^\_\`\{\}\|\~]+|"([\x01-\x08\x0B\x0C\x0E-\x1F\x21\x23-\x5B\x5D-\x7F]|\\[\x0-\x7F])*"))*@([A-Za-z0-9]([A-Za-z0-9\-]*[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0-9\-]*[A-Za-z0-9])?)*|(1[0-9]{0,2}|2([0-4][0-9]?|5[0-4]?|[6-9])?|[3-9][0-9]?)(\.(0|1[0-9]{0,2}|2([0-4][0-9]?|5[0-5]?|[6-9])?|[3-9][0-9]?)){2}\.(1[0-9]{0,2}|2([0-4][0-9]?|5[0-4]?|[6-9])?|[3-9][0-9]?))$/;
  2. var CheckValue = this.value.text.value;
  3. if(!CheckValue.match(RegExpMail))
  4. {
  5. xfa.host.messageBox("E-Mail address is not valid!");
  6. this.font.fill.color.value = "255,0,0";
  7. }
  8. else
  9. {
  10. this.font.fill.color.value = "0,0,0";
  11. }
To avoid invalid characters while typing you also can use this script in the change:Event of the field.
  1. if(xfa.event.newText.match(/[^0-9A-Za-z\.\;\@\_\-\[\]]/))
  2. {
  3. xfa.event.change = "";
  4. }

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

gombear
Registered: Oct 6 2011
Posts: 18
Hi Zadzmar,

Thank you for your help.
But when I tried your exitEvet script, I got this error.
Error: syntax error near token '/' on line2, column 18.

It tried with single quote and double on value of RegExpMail, but still the same error.
Any suggestion?
Thanks,
Gombear
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
The script is written in JavaScript.
Your might have selected FormCalc as language in the script editor.

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

gombear
Registered: Oct 6 2011
Posts: 18
Thank you so much Radzmar!
It worked. You're the best. Now if you can help me with adding days problem on my posting.....