E-mail address validation

T

TBell506

Is there a way to set up a field where there's validation that the format is
a valid email address? For example, I have any number of characters before
the @ symbol then any number of characters before the . symbol then three
characters. Does that make sense? Any help would be really great! Thanks
in advance.
Tracy
 
J

John W. Vinson

Is there a way to set up a field where there's validation that the format is
a valid email address? For example, I have any number of characters before
the @ symbol then any number of characters before the . symbol then three
characters. Does that make sense? Any help would be really great! Thanks
in advance.
Tracy

What makes you think that's the only valid email addresses possible?

(e-mail address removed)

would be a perfectly valid address. So would

(e-mail address removed)

This isn't a trivial problem at all!
 
A

Allen Browne

Simplest approach would be to open your table in design view, and add a
validation rule on the field.

Something like this:
Is Null OR ((Like "*?@?*.?*") AND (Not Like "*[ ,;]*"))
where you put the invalid characters inside the square brackets.

For an explanation of validation rules, see:
http://allenbrowne.com/ValidationRule.html
 
D

David W. Fenton

Is there a way to set up a field where there's validation that the
format is a valid email address? For example, I have any number
of characters before the @ symbol then any number of characters
before the . symbol then three characters. Does that make sense?
Any help would be really great! Thanks in advance.

I've cribbed this Regular Expression from others. I use it in the
email scripts on my web pages:

^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$

This informative, pragmatic and sensible article:

http://www.regular-expressions.info/email.html

....considers the subject and the drawbacks of various approaches. It
even offers the RegEx that is supposed to implement the exact RFC
for valid email addresses. Here it is:

(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(
?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b
\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](
?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\
..){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\
x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e
-\x7f])+)\])

Wisely, that article recommends *not* using this RegEx. :)
 
J

John W. Vinson

It
even offers the RegEx that is supposed to implement the exact RFC
for valid email addresses. Here it is:

(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(
?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b
\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](
?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\
.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\
x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e
-\x7f])+)\])

Wisely, that article recommends *not* using this RegEx. :)

Thanks, David!

As I said: not trivial!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top