Jump to content

Phone Number Validation


phpretard

Recommended Posts

I got this from the ereg documentation, try this one:

<?php if (ereg("^((\([0-9]{3}\) ?)|([0-9]{3}-))?[0-9]{3}-[0-9]{4}$",$homephone)) ?> 

 

to make it clear:

^ means begin here (startpoint of ereg)

$ means end here (endpoint of ereg)

* stand for endless characters (I want A-Z, a-z, 0-9 and the other characters to apear from 0 to endless

optional you can write {1,5} for

min 1 times a character or max 5 times a

characters instead of *

{1,2} means min 1 time a character and max 2 times a character (optional you can write * intead of {1,2}

{1} stand for max 1 time a character

\ means from here special characters (like .-_$ and so on)

| means OR

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.