Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/clinic.corals.io/resources/assets/js/custom/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/clinic.corals.io/resources/assets/js/custom/input_price_format.js
'use strict';

window.setPrice = function (selector, price) {
    if (price != '' || price > 0) {
        if (typeof price !== 'number') {
            price = price.replace(/,/g, '');
        }
        let formattedPrice = addCommas(price);
        $(selector).val(formattedPrice);
    }
};

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

window.getFormattedPrice = function (price) {
    if (price != '' || price > 0) {
        if (typeof price !== 'number') {
            price = price.replace(/,/g, '');
        }
        return addCommas(price);
    }
};

window.priceFormatSelector = function (selector) {
    $(document).on('input keyup keydown keypress', selector, function (event) {
        let price = $(this).val();
        if (price === '') {
            $(this).val('');
        } else {
            if (/[0-9]+(,[0-9]+)*$/.test(price)) {
                $(this).val(getFormattedPrice(price));
                return true;
            } else {
                $(this).val(price.replace(/[^0-9 \,]/, ''));
            }
        }
    });
};

window.removeCommas = function (str) {
    return str.replace(/,/g, '');
};

priceFormatSelector('.price-input');

Spamworldpro Mini