function maskCC(event) {
var vcc = this.value.replace(/\D/g, '');
this.value = '';
for(var i = 0; i < vcc.length; i++) {
this.value += (i%4==0 && i != 0 ? ' ' : '') + vcc[i];
}
}
document.getElementById('cc').addEventListener('input', maskCC, false);