js正则匹配只能输入有效数字可加小数点 var reg = /^d+.?d*$/; if(value.search(/^d+.?d*$/)===0 && parseFloat(value)>0){//只能输入大于0的有效数 console.log("合法"); }