直接上代码
function isPriceNumber(_keyword){ if(_keyword == "0" || _keyword == "0." || _keyword == "0.0" || _keyword == "0.00"){ _keyword = "0"; return true; }else{ var index = _keyword.indexOf("0"); var length = _keyword.length; if(index == 0 && length>1){/*0开头的数字串*/ var reg = /^[0]{1}[.]{1}[0-9]{1,2}$/; if(!reg.test(_keyword)){ return false; }else{ return true; } }else{/*非0开头的数字*/ var reg = /^[1-9]{1}[0-9]{0,10}[.]{0,1}[0-9]{0,2}$/; if(!reg.test(_keyword)){ return false; }else{ return true; } } return false; } }
?
?