$('input').on('keyup',function(){
this.value = this.value.replace(/[^0-9\.]/g,'');
});
From : https://stackoverflow.com/a/891816/622813
After I tested with <input type="number">
When I type something like 1234a so value is blank
But not with <input type="text"> when I type 1234a value is still 1234
Just wonder why ?
Demo : http://jsfiddle.net/PV2fQ/
Update :
<input type="tel"> this work good ... http://jsfiddle.net/PV2fQ/10/ Why?