How to format amount on keyup with toLocaleString ? using minimumFractionDigits?How do JavaScript closures work?How to horizontally center a <div>?How can I format numbers as currency string in JavaScript?How do I check if an element is hidden in jQuery?How do I remove a property from a JavaScript object?How do I find out which DOM element has the focus?How do I redirect to another webpage?How to check whether a checkbox is checked in jQuery?How to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?
Double redundancy for the Saturn V LVDC computer memory, how were disagreements resolved?
changing number of arguments to a function in secondary evaluation
I accidentally overwrote a Linux binary file
How are you supposed to know the strumming pattern for a song from the "chord sheet music"?
Which I-94 date do I believe?
Best gun to modify into a monsterhunter weapon?
Can you castle with a "ghost" rook?
Is it okay for a ticket seller to grab a tip in the USA?
Are there any financial disadvantages to living significantly "below your means"?
Understanding the point of a kölsche Witz
How can you evade tax by getting employment income just in equity, then using this equity as collateral to take out loan?
Is TA-ing worth the opportunity cost?
What game uses dice with sides powers of 2?
Extremely casual way to make requests to very close friends
Tikzpicture - finish drawing a curved line for a cake slice
Simple Stop watch which i want to extend
Why is transplanting a specific intact brain impossible if it is generally possible?
What are the advantages and disadvantages of Wand of Cure Light Wounds and Wand of Infernal Healing compared to each other?
What does this double-treble double-bass staff mean?
What costs less energy? Roll or Yaw?
Team goes to lunch frequently, I do intermittent fasting but still want to socialize
Dropdowns & Chevrons for Right to Left languages
Christian apologetics regarding the killing of innocent children during the Genesis flood
Y2K... in 2019?
How to format amount on keyup with toLocaleString ? using minimumFractionDigits?
How do JavaScript closures work?How to horizontally center a <div>?How can I format numbers as currency string in JavaScript?How do I check if an element is hidden in jQuery?How do I remove a property from a JavaScript object?How do I find out which DOM element has the focus?How do I redirect to another webpage?How to check whether a checkbox is checked in jQuery?How to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm trying figure out a way to format in live an amount of an input box with local's 'it-IT' and minimumFractionDigits of > 2.
This is my code https://jsfiddle.net/oLgtwjfr/
$(document).on('keyup', '#inputKeyupExample', function(event)
var $this = $( this )
var elementThis = this
var input = $this.val()
$this.val(formatNumber(parseInt(input)))
)
function formatNumber(x)
return x.toLocaleString("it-IT",
minimumFractionDigits: 2 );
I except the formatted output of 25000 to be 25.000,00 on keyup. But the actual output is 2,00.
javascript jquery html formatting
add a comment |
I'm trying figure out a way to format in live an amount of an input box with local's 'it-IT' and minimumFractionDigits of > 2.
This is my code https://jsfiddle.net/oLgtwjfr/
$(document).on('keyup', '#inputKeyupExample', function(event)
var $this = $( this )
var elementThis = this
var input = $this.val()
$this.val(formatNumber(parseInt(input)))
)
function formatNumber(x)
return x.toLocaleString("it-IT",
minimumFractionDigits: 2 );
I except the formatted output of 25000 to be 25.000,00 on keyup. But the actual output is 2,00.
javascript jquery html formatting
add a comment |
I'm trying figure out a way to format in live an amount of an input box with local's 'it-IT' and minimumFractionDigits of > 2.
This is my code https://jsfiddle.net/oLgtwjfr/
$(document).on('keyup', '#inputKeyupExample', function(event)
var $this = $( this )
var elementThis = this
var input = $this.val()
$this.val(formatNumber(parseInt(input)))
)
function formatNumber(x)
return x.toLocaleString("it-IT",
minimumFractionDigits: 2 );
I except the formatted output of 25000 to be 25.000,00 on keyup. But the actual output is 2,00.
javascript jquery html formatting
I'm trying figure out a way to format in live an amount of an input box with local's 'it-IT' and minimumFractionDigits of > 2.
This is my code https://jsfiddle.net/oLgtwjfr/
$(document).on('keyup', '#inputKeyupExample', function(event)
var $this = $( this )
var elementThis = this
var input = $this.val()
$this.val(formatNumber(parseInt(input)))
)
function formatNumber(x)
return x.toLocaleString("it-IT",
minimumFractionDigits: 2 );
I except the formatted output of 25000 to be 25.000,00 on keyup. But the actual output is 2,00.
javascript jquery html formatting
javascript jquery html formatting
asked Mar 27 at 8:36
fran openeyfran openey
12 bronze badges
12 bronze badges
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I'm not sure the input box supports that kind of functionality without a lot of extra programming. Also, it would become messy for the user to edit or change the value with lots of numeric formatting in place in that text box.
Instead, consider a formatting display separate to the input like the following:
https://jsfiddle.net/declanmcd/nuy9q5g4/4/
So instead of
$this.val(formatNumber(parseInt(input)));
use
$("#output").text(formatNumber(parseInt(input)));
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55372827%2fhow-to-format-amount-on-keyup-with-tolocalestring-using-minimumfractiondigits%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I'm not sure the input box supports that kind of functionality without a lot of extra programming. Also, it would become messy for the user to edit or change the value with lots of numeric formatting in place in that text box.
Instead, consider a formatting display separate to the input like the following:
https://jsfiddle.net/declanmcd/nuy9q5g4/4/
So instead of
$this.val(formatNumber(parseInt(input)));
use
$("#output").text(formatNumber(parseInt(input)));
add a comment |
I'm not sure the input box supports that kind of functionality without a lot of extra programming. Also, it would become messy for the user to edit or change the value with lots of numeric formatting in place in that text box.
Instead, consider a formatting display separate to the input like the following:
https://jsfiddle.net/declanmcd/nuy9q5g4/4/
So instead of
$this.val(formatNumber(parseInt(input)));
use
$("#output").text(formatNumber(parseInt(input)));
add a comment |
I'm not sure the input box supports that kind of functionality without a lot of extra programming. Also, it would become messy for the user to edit or change the value with lots of numeric formatting in place in that text box.
Instead, consider a formatting display separate to the input like the following:
https://jsfiddle.net/declanmcd/nuy9q5g4/4/
So instead of
$this.val(formatNumber(parseInt(input)));
use
$("#output").text(formatNumber(parseInt(input)));
I'm not sure the input box supports that kind of functionality without a lot of extra programming. Also, it would become messy for the user to edit or change the value with lots of numeric formatting in place in that text box.
Instead, consider a formatting display separate to the input like the following:
https://jsfiddle.net/declanmcd/nuy9q5g4/4/
So instead of
$this.val(formatNumber(parseInt(input)));
use
$("#output").text(formatNumber(parseInt(input)));
answered Mar 27 at 9:56
DeclanMcDDeclanMcD
1,0732 gold badges17 silver badges29 bronze badges
1,0732 gold badges17 silver badges29 bronze badges
add a comment |
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55372827%2fhow-to-format-amount-on-keyup-with-tolocalestring-using-minimumfractiondigits%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown