I am looking for a way to insert a space after 4 numbers in a text box.
Example: XXXX XXXX XXXX
I managed to get an interval without arrow keys or arrow keys without interval.
I looked at this question and several others on the site, but I was not able to solve the problem with reverse space and arrow keys.
Here is my code:
function isNumber(event) {
event = (event) ? event : window.event;
var charCode = (event.which) ? event.which : event.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57)) {
return false;
}
return true;
}
And here is the JSFiddle . This example is very close, but I did not quite understand the interval.
Is it possible to do this with my current function, or do I need to approach this differently?
EDIT : Is it possible to add the functionality of the arrow keys if the cursor does not allow to return to the background after releasing?