Well, I'm not really sure if this will work with ereg(), but if you also have access to PCRE, this'll work with pcre_match()...
/(([0-9]{3})?)(-?)[0-9]{3}-?[0-9]{4}/
This will match any of the following numbers...
123-456-7890
1234567890
456-7890
4567890
bbBear wrote:
Hi.
I'm having problem with the ereg function. Sorry that I'm quite new to PHP.
I wanted to have a validation check on contact number on the form field.
how do I check for the contact number with the following criteria:
1) if it is an ordinary number like ,3344556, it stays valid,
2) if it is mobile, like, 011-4455667, it stays valid as well
3) No characters allow, except '-'
Thanks for help!