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