Validate Phone Number

dogs4kids

New member
Local time
Today, 02:53
Joined
Mar 12, 2009
Messages
5
I have a field with the US phone number mask applied. I can validate the first 3 digits of the field to require a valid area code, but how can I validate the remaining 7 digits to prevent users from doing an end run around the required field by entering all zeros instead of a vaild phone number?
 
welcometoawf.png


1. Unless you have a table of area codes to check it will be darned near impossible to validate this.

2. You can set some validation (I hope you aren't planning on working in the table directly - or having users do so, but using a form which can then be used for validation a whole lot easier) on the control's Before Update event.
 
Thanks for the quick response.

The area codes I have handled--it's the remaining 7 digits that have me stumped. And yes, the data is being entered in a form. I need to verify that neither the 3-digit prefix nor the last 4 digits are all zeros. In other words, something like (303) 000-1234, (303) 000-0000, or (303) 894-0000 would not be allowed.
 
how about that before update event?
Code:
if right(me.textbox, 4) = "0000" OR _
  mid(me.textbox, 7, 3) = "000" then
    mgsbox "The number entered is not a valid phone number, please reenter"
      CANCEL = TRUE
end if
 
The phone number is all one field with the aforementioned mask applied. I set a validation rule for the first 3 characters in the field so that it only accepts number combinations that are valid area codes for my location. I would like to use the code suggested, so what do I need to change to use it?
 
Finally had time to get it to work! Thank you very much, ajetrumpet!
 

Users who are viewing this thread

Back
Top Bottom