日期:2014-05-16 浏览次数:20339 次
function test(){ var len=document.getElementById('id').value.length; var reg = /\s{1,}/g; var card_ = ""; var card=document.getElementById('id').value; //去除空格 card = card.replace(reg,""); for(var i = 0;i < len;i++){ if(i == 1||i == 3 ||i == 5||i == 7||i == 9) { card_ = card_ + card.charAt(i) + " "; } else { card_ = card_ + card.charAt(i); } } document.getElementById("id").value = card_; }