Comments (3)
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.
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.
closed due to inactivity
from persian-tools.
Related Issues (20)
- Migrate from jest to vitest
- fastest-levenshtein error
- getBankNameFromCardNumber issue HOT 3
- phoneNumberValidator method can't accept phone numbers that start with '0900'' HOT 9
- timeago calculate wrong date HOT 6
- Does @persian-tools support float number? example: 5.3 پنج و سه دهم
- Validate Iranian national number bug HOT 1
- Compiled windows version? HOT 4
- Uncaught RangeError: Maximum call stack size exceeded HOT 6
- phoneNumber must be English digits, not support persian number HOT 1
- divide package to multi packages HOT 4
- not work phoneNumberValidator for 996 prefix HOT 2
- PersianTools: convertToTimeStamp - The input format must be yyyy/mm/dd hh:mm:ss HOT 1
- `phoneNumberDetail` method has incorrect typings HOT 2
- incompatible module with node HOT 1
- phoneNumberValidator does not support all mobile number formats HOT 2
- Wrong result of toPersianChars HOT 4
- getShebaInfo method does not work HOT 5
- maximum call stack size excceded error HOT 1
- NumberToWords HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from persian-tools.