473,761 Members | 2,384 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

email and phone number validation

29 New Member
Hello friends........ ....

i am trying to get a validation for email and phone number. in my php project i am doing the validation using java script. but i am not getting validations for email and phone number correctly...

please give a solution for this..
Mar 11 '08 #1
2 3082
dlite922
1,584 Recognized Expert Top Contributor
Hello friends........ ....

i am trying to get a validation for email and phone number. in my php project i am doing the validation using java script. but i am not getting validations for email and phone number correctly...

please give a solution for this..
tell us what your javascript looks like, usually you can change the same regex implemented in PHP.

post your js validations and i'll help you convert them to PHP.
Mar 11 '08 #2
ronverdonk
4,258 Recognized Expert Specialist
Found some routines I use:

Matching US phone numbers in the following formats:

###-###-####
(###) ###-####
##########

Restricts area codes to >= 200 and exchanges to >= 100, since values below these are invalid.[php]$pattern = "/(\([2-9]\d{2}\)\s?|[2-9]\d{2}-|[2-9]\d{2})"
. "[1-9]\d{2}"
. "-?\d{4}/";[/php]
US zip pattern 5 digits (01234) or 5 digits + 4 (01234-1234)
[php]$pattern = '^[0-9]{5}([- /]?[0-9]{4})?$^';[/php]

Email verification[php]if (preg_match("/^[0-9a-z]+(([\.\-_])[0-9a-z]+)*@[0-9a-z]+(([\.\-])[0-9a-z-]+)*\.[a-z]{2,4}$/i", $email)) [/php]

Ronald
Mar 11 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
11735
by: Srinivas Kollipara | last post by:
Hey guys, i have a small question in C#. I have a windows form which has Address fields, zip code and phone number fields. it is working fine with U.S. but i need to modify that for all the other countries. is there any way i can validate zipcode and phone numbers.... Thanks in advance. bye Srinivas
2
3275
by: Jeff Kiesel | last post by:
Has anyone used three textboxes for phone number input and successfully validated it? One textbox for area code, one for exchange, one for number. (yes, we're only doing US numbers) :o)
10
14304
by: JackM | last post by:
I'm still working on validating the phone numbers that are entered on a form but have come across a problem I don't understand how to fix. I can handle most instances when it's in regular US formats (555-555-5555 or (555) 555-5555 or 555 555 5555) but I'm having trouble when the entry is ten consecutive numbers with nothing else (5555555555). Not only does it not validate, but it shows as 2147483647 when I call the variable to check to see...
6
27684
by: Michael R | last post by:
I haven't found anything that would help me to understand the correct syntax for having a certain number of digits phone number validation rule. My input mask for this field is: \000\-0000000;; When I set the following validation rule: 9999999999 or =9999999999 it doesn't work correctly and it allows short numbers. How should I compose it correctly. Thanks, Michael.
2
2194
by: komaladevi | last post by:
hello all ! Can any one help me in validating US Phone Number , I wrotethe javascript for this to get the phone number as 123-234-1234 but i dont know the reason why i am getting this format only after entereing the 11 digit can anyone tell me how can i solve this problem or can anyone help me to get this format for us phonenumbers. I want the code like while entering the digits only i should get "-" at the 4th and 8th positions and...
3
2249
by: ryushinyama | last post by:
I am wanting to remove 1's that Canadian customers put in front of their numbers because when FedEx imports them for shipping they leave the 1 and cut off the last number. Other countries numbers don't get formatted the same so they are not an issue. The code below was an attempt to remove a one at the beginning if present at all. Which should get the job done but I don't know if there are countries out there that need to start in the...
6
1973
by: emirapoport | last post by:
Hello, im posting this question because i have zero knowledge on javascrip. I have a script which curently allows users to imput an email address and if the email is not valid it wont allow the submission. Everything works fine except that now there are clients who have a period in their email address and it is rejected. eg. tom.jones@email.com.. im sure its a simple addition to the script not even sure where it might go but here is what i...
4
2508
by: emirapoport | last post by:
Hello, im posting this question because i have zero knowledge on perl. I have a script which curently allows users to input an email address and if the email is not valid it wont allow the submission. Everything works fine except that now there are clients who have a period in their email address and it is rejected. eg. tom.jones@email.com.. im sure its a simple addition to the script not even sure where it might go but here is what i copied and...
8
2917
by: nargis2009 | last post by:
Hi, I have been encountering problems with my web page which is supposed to send email, and wondered if anybody can help find error. Initially I had all codes in one page and on click of Submit it would send email. But then I wanted to give a user an opportunity to go back and edit the entries if incorrect before submitting. I separted the codes into two pages. On the second page when Submit button is clicked it should send email. But...
0
9522
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10111
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9902
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8770
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7327
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6603
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5364
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3866
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3446
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.