Total Pageviews

Friday, 19 July 2013

PDF: Validate Email address in PDF Form

Please following tutorial to validate an email address on your Adobe LiveCycle Designer Form

  1. Create a new Form.
  2. Add a Text Field to it.
  3. Go into the Object –> Value window of the Text field
  4. Choose –> validation Script Message (error)
  5. Create a message saying that the mail address is wrong.
  6. Go into the Script Editor (CTRL-SHIFT-F5).
  7. Put in this little script as a JavaSscipt (run at Client)

var r = new RegExp();
r.compile("^[a-z0-9_-.]+@[a-z0-9_-.]+.[a-z]{2,3}$","i");
var result = r.test(this.rawValue);
if (result == true)
  true;
else
  false;



Add a button that validates your form like the Email Submit Button.

Done...

// report error if there is an invalid email address when the field is not empty.
if (! eMailValidate(event.value) && event.value != "") {
event.rc = false;
app.alert({
cMsg: "Invalid email address - Please try again",
cTitle: "Acme Testing Service",
nIcon: 0,
nType: 1
});
} // end if validation test


Or only run the script if the field is not empty:

if(event.value != "") {
if (! eMailValidate(event.value)) {
event.rc = false;
app.alert({
cMsg: "Invalid email address - Please try again",
cTitle: "Acme Testing Service",
nIcon: 0,
nType: 1
});
} // end if validation test
} // end non-null field

No comments:

Post a Comment