首页 > 移动平台 > 详细

金额验证 适用手机端

时间:2015-12-02 18:22:52      阅读:270      评论:0      收藏:0      [点我收藏+]
1 <input type="number" placeholder="1.00元" name="get_price" id="get_price" max="1000">

 


 1 $("#get_money").keyup(function(){
 2      var money = $("#get_money").val();
 3      var re = /^(-)?(([1-9]{1}\d*)|([0]{1}))(\.(\d){1,2})?$/ ;
 4      if(!re.test(money)){
 5 
 6         if(money.indexOf(".")==1 && money.length==2){
 7 
 8         }else if(money.length ==5){
 9             $(this).val(money.substr(0, 4));
10 
11         }else if(money.substr(0, 2)!=‘0.‘&& money.substr(0, 1)==0){
12 
13             $(this).val(money.substr(1, 2));
14 
15         }else if(money.length >3){
16 
17             $(this).val(parseFloat(money).toFixed(2));
18         }
19         
20      }
21   })

 



  

金额验证 适用手机端

原文:http://www.cnblogs.com/kellie/p/5013514.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!