Home >Web Front-end >JS Tutorial >JS method to determine whether the input string is a number (regular expression)
Examples are as follows:
if (!checkNumber(gopage_val)) { alert("请输入正确页数(数字)"); return false; } //验证字符串是否是数字 function checkNumber(theObj) { var reg = /^[0-9]+.?[0-9]*$/; if (reg.test(theObj)) { return true; } return false; }