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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.