title: How to remove characters when user is typing in javascript
body: <p>i am validating an input box value so that <code>it should contain only digit,.,-,/</code> if at any time user type any thing accept allowed character, then only that character should get removed.</p>
  
  <p>ex. if i typed initially 12/12/ then a, then only a should get removed from text box not whole string 12/12.</p>
  
  <p>what i have tried so far.-</p>
  
  <pre><code>&lt;input type="text" onkeyup="isValidDate(this);"/&gt;
  function isValidDate(f){ 
      var re =/^[\d\/\.-]+$/;
     if (!re.test(f.value)) { 
      alert("called");
      f.value = f.value.replace(/^[\d\/\.-]+$/g,"");
     }
   }
  </code></pre>
  
  <p>i am  getting alert but un wanted value is not getting removed.</p>
  
  <p>How i can do this using java script?</p>