正则表达式(限制text只允许输入int ,float) function numberCheck (text) { var regex = /^[+|-]?\d*\.?\d*$/; if (!regex.test(text)){ return false; } return true; }