const maxNumLength = 4;
event = jQuery.Event("keypress")
event.which = 13
$('#input').on('input focus keydown keyup', function() {
const inputValue = $(this).val();
const linesArray = inputValue.split(/(\r\n|\n|\r)/gm);
for (let j = 0; j < linesArray.length; j++) {
if (linesArray[j].length > maxNumLength) {
linesArray[j] = linesArray[j].substring(0, maxNumLength);
}
}
$(this).val(linesArray.join(''));
});
I have implemented the code to move numbers to the next line after every 4 digits, but it does not seem to be working. Can someone please provide guidance on how to fix this issue?