0

My SharePoint application is now in German regional settings. Hence, numbers takes format as 1.000,00 (for 1 thousand) instead of 1,000.00. Is there a way to handle numbers in german format in jquery.

e.g. Amount=1.000,00 / 25,00. 

Jquery gives error as NaN when doing above calculation.

my approach:

  1. convert above numbers to english numbers (1000.00 & 25.00)

  2. do jquery calculation (1000.00 / 25.00)

  3. convert result (40,00) back to german format.

My approach is tedious since i have to deal with many such calculation in my application. Please suggest some better approach.

5
  • What do you want to do exactly? Is an calculated column or an workflow an option?
    – Patrick
    Jul 19, 2016 at 7:08
  • Where are you getting your German format numbers from? From the DOM, somewhere on the page?
    – Submits
    Jul 19, 2016 at 8:09
  • @Patrick, Its a Number type column in SP list form. I want to do division operation e.g. Result = (Amt / Currency) Jul 19, 2016 at 10:39
  • @Submits, Amt is the user inputs and I dont know what user will input. User can input english format (1,000.25) or German format (1.000,25). Jul 19, 2016 at 10:41
  • Yes but how are you obtaining the value or Amt? From the DOM via jQuery? From a context object? From a REST call?
    – Submits
    Jul 19, 2016 at 10:52

2 Answers 2

0

The simplest trick for solving this would be to define a function in your js file which will remove the commas or dots between the numbers, like a simple replace will do. And then perform the calculation

1
  • Yes ThatThatGuy, I applied the same trick but I have to apply the same function everywhere where numbers are used by my application. Any better alternative? Jul 19, 2016 at 8:01
0

You can use jquery-numberformatter to convert or handle numbers from German.

Jquery NumberFormatter

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.