Giter Site home page Giter Site logo

Comments (3)

mediv0 avatar mediv0 commented on May 29, 2024 1

hi,
thanks for reporting this bug

about this behavior ( 5,0,0,0,000 ):
first, you have to remove commas from your input then passing it into the addCommas function
Also, you have to wait for PersianTools to load then using it otherwise you will get undefined error;

for now you can change your code to something like this:

<script type="text/javascript">

    let PersianTools;
    window.addEventListener("load", (event) => {
        PersianTools = this["persian-tools"];
    });

    $("#PostPriceCity").on("keyup", function () {
        var GetValue = $(this).val();
        let val = GetValue.replace(/,/g, "");
        val = PersianTools.addCommas(val);
        $(this).val(val);
    });

</script>

from persian-tools.

ali-master avatar ali-master commented on May 29, 2024 1

Hi @mahmudipur Jan,

Thanks for using the PersianTools in your project, we appreciate it a lot.

The problem is you want to add commas to the amount string whereas it includes commas already when its length goes more than 3, So, But as @mediv0 said before, you need to use the PersianTools' removeCommas function before applying the GetVal to addCommas to ensure that the string is clear of comma keywords and then add commas to the amount string.

Sample:

<script type="text/javascript">
    $("#PostPriceCity").on("keyup", function () {
        var GetValue = $(this).val();
        var sanitizedAmount = PersianTools.removeCommas(GetValue);
        var amountWithCommas = PersianTools.addCommas(sanitizedAmount);
        $(this).val(amountWithCommas);
    });
</script>

from persian-tools.

mediv0 avatar mediv0 commented on May 29, 2024

closed due to inactivity

from persian-tools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.