xiasf
3/1/2018 - 6:59 AM

限制input合法数据

限制input合法数据

$('.ser_num').bind('input', function () {
    var that = $(this);
    var defaultVal = 1;
    var oldVal = that.data('oldVal') || defaultVal;
    var val = parseInt(that.val());
    if (isNaN(val) || val < 0) {
        that.val(oldVal);
        return;
    }
    that.val(val).data('oldVal', val);
    getTotal();
});