I\'m really new in JavaScript and I would like to add to my input text, space insertion for IBAN account registering.
This is the shortest version using JQuery on input with type number
or tel
:
$('input[type=number], input[type=tel]').on('input', function (e) {
e.target.value = e.target.value.replace(/[^\dA-Z]/g, '').replace(/(.{4})/g, '$1 ').trim();
});
You can also change the 4 to any other character limit you want.