Phone number validating in php
<p>I would like to "validate" my posted phone number. I don't really care about the format, i just want to use only numbers and some chars.
I tried this code, but if i type at least one number to my string then string will be valid. (for ex.: asdafadas-1asd will be valid)
 How to fix this?</p>

<pre><code>$phonebool=true;
       if (!(strcspn($_POST['phone'], '0123456789-/ ') != strlen($_POST['phone']) )){
           $_SESSION['phone_err']='Only numbers and -/';
           $phonebool=false;
       }
</code></pre>

<p>thank you.</p>
