allora intanto ereg è deprecata devi usare preg_match

prova così

Codice PHP:
if(!preg_match("[0-9]+$",$_POST['telefono'])){