HTML input allow only numeric values | JavaScript

Following code allows exactly numbers and one decimal, but no more.
<input type="text" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*?)\..*/g, '$1');" />
run this source code Browser View

Numbers and One decimal, but no more.

Full Source | JavaScript
<!DOCTYPE html> <html> <body> <h2>Numbers and One decimal, but no more.</h2> <input type="text" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*?)\..*/g, '$1');" /> </body> </html>

Allow only numeric values

How do I make a textbox that only accepts numbers? Javascript
By default, HTML 5 input field has attribute type="number" that is used to get input in numeric format. But you can force input field type="text" to accept numeric values only by using Javascript or jQuery. There are so many ways you can force the input field to take input only numbers.