question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature request] Add two 'format' and 'unformat' methods

See original GitHub issue

I frequently need to test formatted/unformatted data against values from an autoNumeric managed input.

I wish I could do something like :

let myOptions = { aSep: '.', aDec: ',', altDec: '.', aSign: ' €', pSign: 's', mRound: 'U' };
let autoNumInput = $(el).autoNumeric('init', myOptions);

let unformattedValueXXX = "2222.67";
let formattedValueXXX = autoNumInput.autoNumeric('format', unformattedValueXXX); //"2.222,67 €"

let formattedValueYYY = "678.000,32 €";
let unformattedValueYYY = autoNumInput.autoNumeric('unformat', formattedValueYYY); //678000.32

…using the autoNumericInput as a ‘factory’ to format/unformat given number/strings.

That would allow us to not have to code an unformat function to do that myself (and defeat the purpose of the multiple autoNumeric format options), and not reinventing the autoNumeric wheel.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
BobKnothecommented, Jan 13, 2017

Name spacing would require a major re-write which I am not prepared to do at this time.

I just finished the $.fn.autoFormat("value", {options}); need to check for bugs.

Next will be $.fn.autoUnformat("value", {options});

You could always attach the options as data to some element - yes i know it’s not elegant.

0reactions
AlexandreBonneaucommented, Jan 27, 2017

Those functions are callable via the jQuery wrapper, or directly when aN is imported as a module. The work is done here, thanks @BobKnothe!

note: the IDE autocompletion will be improved in the near future

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fully convert autoNumeric to an ES6 module · Issue #399
In the former case, we can use the AutoNumeric class directly to format/unformat numbers and strings, without having to use a DOM element....
Read more >
String.Format Method (System) - Microsoft Learn
Replaces the format items in a string with the string representation of two specified objects. A parameter supplies culture-specific formatting information.
Read more >
Feature Requests - DecoNetwork Help
Feature Requests ; Automatically recieved stock when an order is cancelled. Timothy Pipp ; Add option for additional area discounts to all decoration...
Read more >
3 ways to manage software feature request - Amoeboids
Discover best practices to manage feature requests from different stakeholders. Practical tips to get you on top of the game.
Read more >
How to Format SD Cards in All Devices - EaseUS
Method 2. Format SD Card Use Disk Management. Step 1. Insert your SD card into a card reader and connect it to your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found