function forcheck(str) { var type = "^[0-9]*[1-9][0-9]*$"; var re = new RegExp(type); if (str.match(re) == null) { alert("请输入正整数!"); return; } }