Expand my Community achievements bar.

SOLVED

email validate

Avatar

Level 1

I have an email field on a form and cannot seem to get the validation to work.  Any entry seems to fail validation.  This wouldn't be a huge problem, but I want the form to be able to be submitted via email and it will not work without a valid email.

any and all help would be greatly appreciated.

thank you

1 Accepted Solution

Avatar

Correct answer by
Level 7

Could you post the form you're having trouble with?

View solution in original post

5 Replies

Avatar

Correct answer by
Level 7

Could you post the form you're having trouble with?

Avatar

Level 7

Try putting this script into validate event:

// Validate the email address.

var r = new RegExp(); // Create a new Regular Expression Object.
    r.compile("^[a-z0-9_\\-\\.]+\\@[a-z0-9_\\-\\.]+\\.[a-z]{2,3}$","i");// 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.

That should take care of it.

Avatar

Level 1

please excuse my ignorance, but where do i put that code?

Avatar

Level 7

No problem, here's how to do it:

1. Open the form with Designer

2. Press Ctrl+Shift+F5 to open the Script Editor

3. Click on the email field you need validated

4. In the Script Editor window, click on the drop down list on the top left.

It will say "Events with Scripts" by default. Select "validate" from the list that pops up.

5. Paste in the script I posted earlier

6. Make sure you have JavaScript selected in the Language drop down box on the

top right of the Script Editor

7. Preview the PDF and type in an invalid email address to make sure you get a

message popping up telling you the address is invalid.