MC-XOBAHCK,
<input type="text" id="test">
<script>
document.querySelector('#test').addEventListener('input', function() {
this.value = this.value.replace(/,/, '.').replace(/\./g, function(a, b, c) {
return c.indexOf(a) == b ? a : ''
}).replace(/[^\d.]/, '');
});
</script>