验证金钱只允许数字和小数点后两位

function check_input_money(obj)
{
     rtn_val = $(obj).val().replace( /[^\d|\.]/g, '');
     var price = /^\d+(\.\d{0,2})?/.exec(rtn_val);
    if(price != null){
        unit_price = price[0];
        $(obj).val(unit_price);
    }else{
     $(obj).val('');
    }
}
posted on 2014-12-11 10:40  面壁偷笑  阅读(192)  评论(0编辑  收藏  举报