正则精确到小数点后两位

1     var price = e.detail.value;
2     // if (!(/^\d+\.[0-9]{2}/).test(price)) {
3     if (price.match(/^\d{1,7}(\.\d{0,2})?$|^\.\d{1,2}$/)){
4       defaultPrice = price;
5       return price;
6     }else{
7       return defaultPrice;
8     }

 

posted @ 2018-07-24 09:12  zwb8032fang  阅读(714)  评论(0编辑  收藏  举报