In my form I have a text field in which user type date. Good habit tells me to not let user to put anything other then dgit and '-' symbol in the field.
However i have a bit problem with implementing such feature. So far I Have a field which accept only digits. If user try to put in field letter, this letter is being removed. But the point is to create (DD-MM-YYYY)
format so field have to accept '-' symbol.
Here is my code:
<input type="text" name="test3" placeholder='DD-MM-YYYY' onkeyup="if (/\D/g.test(this.value)) this.value = this.value.replace(/\D/g,'')"/>
i tried put |\-
into regex but with no success. Can anyone point me where I am doing mistake?