方法1.可以采用正则表达式 var reg = /^\d+$/;var str = "123";reg.test(str) ; 转载于:https://www.cnblogs.com/yiliweichinasoft/archive/2013/04/19/3031630.html