JS验证监听输入银行卡号

$("#AccountNum").keydown(function(e) {
    if(!isNaN(this.value.replace(/[ ]/g,""))){
        this.value =this.value.replace(/\s/g,'').replace(/(\d{4})(?=\d)/g,"$1 ");//四位数字一组,以空格分割
    }else{
        if(e.keyCode==8){//当输入非法字符时,禁止除退格键以外的按键输入
            return true;
        }else{
            return false
        }
    }
});

猜你喜欢

转载自www.cnblogs.com/init-007/p/11669594.html