PHP: How to use ereg to validate input text AND string length simultaneously?

Posted by Andrew on Stack Overflow See other posts from Stack Overflow or by Andrew
Published on 2010-03-14T15:51:08Z Indexed on 2010/03/14 15:55 UTC
Read the original article Hit count: 289

Filed under:
|

Hi, I'm using ereg in the followin way to validate a field which can contain only numbers from 0 to 9:

if(eregi("^([0-9])*$", $mynumber)) return true;

However the string must have between 8 and 10 characeters. Is it possible to improve the same ereg usage to check for a valid string length as well?

Thanks in advance.. all ereg tutorials seem to be traditional chinese to me. :S

© Stack Overflow or respective owner

Related posts about php

Related posts about ereg