const input = document.querySelector('input')
//Add space e.g 1234 5678 9012
input.innerHTML = input.value.replace(/\d{4}(?=.)/g, '$& ');