How to create an input mask for e-mails

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi. I want to create an input mask for e-mails in order to force people to
insert the @ and the . (dot).

Any one can help me?

Marco Silva.
 
Hi. I want to create an input mask for e-mails in order to force people to
insert the @ and the . (dot).

Any one can help me?

Marco Silva.

Input masks are not sophisticated enough to do this. Email addresses
are simply too diverse.

Instead, use a Form to do the data entry, and use the textbox's
BeforeUpdate event to (roughly) check for validity. For example, you
could use

Private Sub txtEmail_BeforeUpdate(Cancel as Integer)
If Me!txtEmail & "" = "" Then Exit Sub ' ignore blank emails
If InStr(Me!txtEmail, ".") = 0 Then
Msgbox "Invalid email - must contain a period"
Cancel = True
End If
If InStr(Me!txtEmail, "@") = 0 Then
MsgBox "Invalid email - must contain an @ symbol"
Cancel = True
End If
End Sub

John W. Vinson[MVP]
 
Thanks, worksperfectly.

Regards,
Marco

John Vinson said:
Input masks are not sophisticated enough to do this. Email addresses
are simply too diverse.

Instead, use a Form to do the data entry, and use the textbox's
BeforeUpdate event to (roughly) check for validity. For example, you
could use

Private Sub txtEmail_BeforeUpdate(Cancel as Integer)
If Me!txtEmail & "" = "" Then Exit Sub ' ignore blank emails
If InStr(Me!txtEmail, ".") = 0 Then
Msgbox "Invalid email - must contain a period"
Cancel = True
End If
If InStr(Me!txtEmail, "@") = 0 Then
MsgBox "Invalid email - must contain an @ symbol"
Cancel = True
End If
End Sub

John W. Vinson[MVP]
 
Hi again,

I don't if you ever checked but if your e-mail has a dot it doesn't control.
In i.e. if the e-mail is: (e-mail address removed) if I write
marco.silva@hotmailcom it doesn't check for erros because there is a dot in
the e-mail.

I just think you would like know.

Marco.
 
Hi again,

I don't if you ever checked but if your e-mail has a dot it doesn't control.
In i.e. if the e-mail is: (e-mail address removed) if I write
marco.silva@hotmailcom it doesn't check for erros because there is a dot in
the e-mail.

I just think you would like know.

I did know... thanks.

This is a VERY simple, limited example. I'm sure someone somewhere has
written a VBA routine to check for well-formed EMail strings; if so,
it is certainly long, complex, and tricky. My example was not intended
to be such.

John W. Vinson[MVP]
 

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

Similar Threads

Remove input mask format 4
Input masks 3
Input Mask - Date and Time 7
Input masks 4
input masks 10
How do I use the letter 'L' in an input mask? 1
input mask 4
Input Mask for IP address 1

Back
Top