How to validate input for comma as decimal separator using JS?

Viewed 42

I am currently using this to allow users to enter numbers, but this accepts multiple dots and commas and I'd love to restrict it to a more precise number entry, because God knows the wonders that users can do.

How can I restrict it to comma as decimal separator?

<input oninput="this.value=this.value.replace(/[^0-9.,]+/gmi,'')" value="">

Thanks in advance!

1 Answers

Try following code:

<input onChange="this.value=this.value.replace(/[^A-Z0-9]+/ig, '')" value="">
Related