How can i input only valid telephone number in input box?
<p>I am trying to input a telephone number in an input box like this (ex. 111-222-3333)</p>

<p>so I use this code:</p>

<pre><code>&lt;script type="text/javascript"&gt;
    function validate(evt) {
      var theEvent = evt || window.event;
      var key = theEvent.keyCode || theEvent.which;
      key = String.fromCharCode( key );
      var regex = /[0-9]|\-/;
      if( !regex.test(key) ) {
        theEvent.returnValue = false;
        if(theEvent.preventDefault) theEvent.preventDefault();
     }
    }
&lt;/script&gt;
</code></pre>

<p></p>

<p>I can now only input telephone number using integer(0-9) and '-' but the problem is user can also type another hyphen(‐) after a hyphen(‐).
Or user can type numbers not in a telephone format</p>

<p>Please help me, i really need this one..thanks:)</p>
