I use CakePHP + WAMP on Windows.
My problem is that whenever there is a dash in a pattern and an input string has a dash, no match occurs.
As a result, validation fails.
Here's an example of the code I used:
Code: Select all
function valid_phone($data) {
$pattern = "^[0-9]{3}-[0-9]{4}$";
$phone_no = trim($data['phone']);
if (ereg($pattern, $phone_no))
return 1;
else
return 0;
}
If I add the dash and input something like "123-45657", validation fails.
This is not the only pattern I've tried, all with the same results.
Any ideas?
Thank you!