正则表达式 金额验证

 let reg = /(^[1-9](\d+)?(\.\d{1,2})?$)|(^[1-9]$)|(^\d\.[1-9]{1,2}$)|(^\d\.[0]{1}[1-9]{1}$|(^\d\.[1-9]{1}[0]{1}$)$)/;
 let num = 0.01;
 if (reg.exec(num)) {
     console.log('验证通过');
 } else {
     console.log('验证失败');
 }

 

posted @ 2018-09-26 10:38  Sky_Ice  阅读(4727)  评论(0编辑  收藏  举报