Preg match problem
<p>I try to "validate" a date field. I only want to allow, numeric chars and - character.</p>

<pre><code> $born_date=$_POST['date'];
 $goodchars = array("1","2","3","4","5","6","7","8","9","0","-");
 $char_re_good = '/['.preg_quote(join('', $goodchars), '/').']/';
       if (!(preg_match($char_re_good, $born_date))) {
            echo "not ok, contain INVALID chars"
       }else{
            echo "ok, contain valid chars"
       }
</code></pre>

<p>If i try to search for "1960" then OK. If i try to search for " asdfg" then NOT OK. 
But if i search for "1960/" then the output is OK. I dont understand why. </p>

<p>Could you help me modify to check if user only "0-9" and "-" chars fill out the field.</p>

<p>Thank you</p>
