I trying to write a script using jQuery, it is suppose to automatically put a space after every numbers. in order to separate a sequence of numbers that user input in an input field. e.g. 4444 4444 4444 4444
$('#creditcardnumber').blur(function(){
var creditcardnumber= $(this), val = creditcardnumber.val();
if(val.length > 4)
creditcardnumber.val(val.slice(0, -4)+' '+val.slice(-4));
})