BIG阳
input.onkeypress = function (e) { let enablePoint = true; if (this.value.indexOf('.') != -1) {
enablePoint = false;
} if ((e.keyCode < 48 || e.keyCode > 57) && e.keyCode !== 46) { console.log('非法字符'); return false;
} if (e.keyCode === 46 && !enablePoint) { console.log('已有小数点'); return false;
} if (this.value.match(/^\d*\.\d\d$/g)) { console.log('小数点后只允许两位'); return false;
} return true;
}