Log in

View Full Version : Resolved numeric only



remp
11-22-2010, 03:40 AM
Hello everyone, i have a contact form which has a phone number field, and i want to make it only number,

i have used the following code:

if (preg_match('/^[0-9]{1,}$/', $phone) < 4 ) {
$error['phone'] = "Please enter your phone number.";
}

But for some reason, it does not work, can you give me a hand with this?

Nile
11-22-2010, 03:44 AM
Use is_numeric() (http://php.net/manual/en/function.is-numeric.php).

remp
11-22-2010, 03:52 AM
Thanks, i had tried that before, and it wasnt working, but i found it the error was in another part of the code. and i have changed it to is numeric...

Thank again.

Nile
11-22-2010, 03:53 AM
No problem, I'm glad to help :D

Here on DD, we like to keep things organized. In an effort to do so, you have the option to set a thread to resolved when an issue is fixed. To make the status of the thread resolved:
1. Go to your first post
2. Edit your first post
3. Click "Go Advanced"
4. In the dropdown next to the title, select "RESOLVED"