From what I have seen so far here on stackoverflow, there are some recommendations about the String.replaceAll() function, or using javascript with the input ID. The code below will introduce a space after five characters, but I need it to add the space after the slash character is typed.
For example: if the user is typing abc12c/edfte; I need it to introduce a space after the slash character is typed to obtain this result: abc12c/ edfte.
document.getElementById('target').addEventListener('input', function (e) {
var target = e.target, position = target.selectionEnd, length = target.value.length;
target.value = target.value.replace(/\s/g, '').replace(/(\d{5})/g, '$1 ').trim();
target.selectionEnd = position += ((target.value.charAt(position - 1) === ' ' && target.value.charAt(length - 1) === ' ' && length !== target.value.length) ? 1 : 0);
});
<label id="target" contenteditable="true" type="text"/>someText</label>
I appreciate any guidance.