var regu = "^([0-9]*[.0-9])$"; // 小数测试 var re = new RegExp(regu); var number=12.12; if(number.search(re) == -1){ alert("此数字为小数"); }