Hello All,
I would like to do a simple email validation, the built in email validation pattern(text{OOOOOOOO'@example.com'} ) is not really useful.
What is the best to validate an email in the form which was built using livecycle designer.
Is there any other pattern I can use?
My requirement is simple, the email should contain ‘@’ and a dot, something like ( xxx@xxx.xxx)
Any help is much appreciated.
Thanks and regards,
I manage to solve the problem.
It is simple use the custom email address control.
Alternatively place the following javascript in normal textbox control.
// Validate the email address.
var
r = new RegExp("^[a-z0-9_\\-\\.]+\\@[a-z0-9_\\-\\.]+\\.[a-z]{2,3}$"); // Create a new Regular Expression Object.
// Set the regular expression to look for an email address in general form.
var
result = r.test(this.rawValue); // Test the rawValue of the current object to see
// if it fits the general form of an email address.
if
(result == true) // If it fits the general form,
true; // all is well.
else
// Otherwise,
false; // fail the validation.
Thanks for posting this
Views
Replies
Total Likes
Perfect -- works like a charm! (LCD ES2).
One question: is there any way to make the focus stay on the e-mail field? Because once it produces an error message due to invalid e-mail format, the focus moves to the next field anyway.
I added a couple of tweaks -- (1) to allow for up to 8-character domain suffixes (there are some long ones out there -- "museum", "travel", etc.); (2) allows the user to leave the field empty with the initial if statement; (3) if the field has content, the focus stays on the field if there's a validation error. Thanks to OP Andrew Smith for the script.
if (this.rawValue != null) {
// Create a new Regular Expression Object
var r = new RegExp("^[a-z0-9_\\-\\.]+\\@[a-z0-9_\\-\\.]+\\.[a-z]{2,8}$"); // (allows 2-8 characters in domain suffix)
// Set the regular expression to look for an email address in general form
// Test the rawValue of the current object to see if it fits the general form of an email address
var result = r.test(this.rawValue);
if (result == false) {
xfa.host.messageBox("Invalid e-mail address -- please use format username@domain.xxx","CHECK E-MAIL FORMAT",0,0);
xfa.host.setFocus(this);
}
On a text box > Validation expression, add script below
(this.value && this.value.match(/^[A-za-z0-9]+[\\._]*[A-za-z0-9]*@[A-za-z.-]+[\\.]+[A-Za-z]{2,4}$/i) == null) ? false : true
this should solve your problem
Views
Replies
Total Likes
FulufheloMM, could you please explain exactly how that works?
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies