javascript 正则表达式 验证商品价格、钱数 !
<script type="text/javascript" language="javascript"> function ckProPrice(){ //判断商品价格 var reg =/(^[-+]?[1-9]\d*(\.\d{1,2})?$)|(^[-+]?[0]{1}(\.\d{1,2})?$)/; if($("txtProPrice").value == ""){ $("ProPriceTool").innerHTML = "商品价格不能为空!"; return false; }else{ if(!reg.test($("txtProPrice").value)){ $("ProPriceTool").innerHTML = "市场价格必须为合法数字(正数,最多两位小数)!"; return false; }else{ $("ProPriceTool").innerHTML = ""; return true; } } } </script> <input type="text" id='txtProPrice' /> <span id="ProPriceTool" style="color:Red; padding-left:20px;"></span>
相关推荐
wangzhaotongalex 2020-10-20
wyq 2020-11-11
TLROJE 2020-10-26
风雨断肠人 2020-10-13
duanqingfeng 2020-09-29
rechanel 2020-11-16
cshanzhizi 2020-10-16
luofuIT成长记录 2020-09-22
phphub 2020-09-10
taomengxing 2020-09-07
MaggieRose 2020-08-19
flyingssky 2020-08-18
山水沐光 2020-08-18
jyj00 2020-08-15
AHuqihua 2020-08-09
山水沐光 2020-08-03