<input is="input-separator" id="test" value=""/>
<button onclick="alert(test.value)">Show value</button>
<script>
customElements.define('input-separator', class extends HTMLInputElement {
constructor() {
super();
addEventListener('input', _ => {
this.value = new Intl.NumberFormat('en-GB').format(this.value.replace(/\D+/g, ''));
})
}
}, {extends: 'input'});
</script>
вариант