The line below restrict the input to be numbers only. How can this be adjusted to accept dot and comma?
Numbers only: <input oninput="this.value=this.value.replace(/(?![0-9])./gmi,'')"></input>
Appreciate your help!
The line below restrict the input to be numbers only. How can this be adjusted to accept dot and comma?
Numbers only: <input oninput="this.value=this.value.replace(/(?![0-9])./gmi,'')"></input>
Appreciate your help!
You may replace on the pattern [^0-9.,]+
:
<input oninput="this.value=this.value.replace(/[^0-9.,]+/gmi,'')"></input>
Note that technically we should also disallow more than one decimal point, and we also should not allow thousands comma separators in the wrong place.