Newbie here so hopefully I am just missing something simple here.
Why does the following code always say that it passed the check
$clientnum = "12345";
if (ereg('[^0-9]', $clientnum) && strlen($clientnum) !== 4){
echo "Check failed";
}
else {
echo "Check passed";
}
[code=php]
$clientnum = 1a345 it fails as it should
$clientnum = 12345 if passes it and should not
I want to make sure that $clientnum is only 4 numbers long and is only numbers. If fails I will have a error appear and have the user fix the problem. It works if I only do 1 check but not if I do both of them.
What am I missing here?
Thanks in advance