Skip to content

add comma for decimals : #17

@atsaeid

Description

@atsaeid

add method :

parseDigits: function (value) {
var nStr = value + '';
nStr = nStr.replace(/,/g, "");
var x = nStr.split('.');
var x1 = x[0];
var x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
x1 = x1.replace(rgx, '$1' + ',' + '$2');
}
return (x1 + x2);
}

///-------------------------//
and use it :

_instance.$elem.on('input propertychange', function () {
var parsedValue = _instance.parseValue(_instance.$elem.val());
//custimized comma:
_instance.$elem.val(_instance.parseDigits(parsedValue));
//
_instance.options.callback.call(_instance, parsedValue);
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions