0

In Oracle APEX - I tried to put below JS in Advance-> Custom Attributes property- onfocusout="this.value=Number(this.value).toFixed(4).replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,')"

and in Appearance-> Format mask -> 999G999G999G999G999G999G999G999G990D0000

but in this JS, I am getting result like- 10,000.0,000

I need result as comma separated like- 999G999G999G999G999G999G999G999G990D0000 e.g. 10,000.0000

Note: Decimal should be fixed 4 and rest values should be thousand separator. Please help me if you ever tried this.

Type-> NumberFormat{Plug In} is not working in this case, As I am getting the records from interactive report to update.

Please let me know if more information is required.

Erik Philips
  • 53,428
  • 11
  • 128
  • 150
  • Checkout the format money post here: https://stackoverflow.com/questions/149055/how-to-format-numbers-as-currency-strings/149099#149099 you can probably use something like formatMoney(this.value,4) and get the result you need in JS. – Grasshopper May 14 '21 at 16:17
  • This(formatMoney(this.value,4)) is not working in APEX. – user15926257 May 14 '21 at 16:50
  • onfocusout="this.value=Number(this.value).toFixed(4).replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,')" Above solution is working but result is not as expected. – user15926257 May 14 '21 at 16:51
  • you need to include the formatMoney javacript code in your application's javascript. Either on the page or as a static file. And "Above solution is working but result is not as expected" = not working. The reason it doesn't work is because the regex is looking for 3 digits and adding a comma and there are multiple sets of 3 digits. You can see the format money solution to see how that user wrote his regex if you prefer to continue with that solution but it seems more difficult. – Grasshopper May 14 '21 at 19:32
  • What is your version of apex ? This works for me as you describe out of the box- no custom coding needed. Page item of type "Number Field", format mask "999G999G999G999G990D0000". If I put in "10000" and click anywhere else, the format changes to "10,000.0000". I tested on 20.2 – Koen Lostrie May 16 '21 at 08:53
  • My version is 20.2 as well. But when I put Number field in page item type then it's working. But when I click on edit of interactive report then it fills the data in my form. After that if I try to update the amount column, it's not displaying as 10,000.0000 – user15926257 May 17 '21 at 03:37
  • I want like whenever I update the amount and I click anywhere, it should be in this format 999G999G999G999G990D0000 only. – user15926257 May 17 '21 at 03:53
  • When I use js -onfocusout="this.value=Number(this.value).toFixed(4).replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,')" it's giving me fixed 4 decimal but it's separates the number of counut of 3. – user15926257 May 17 '21 at 03:57

1 Answers1

1

There is no need of custom coding to achieve this.

Please put the format mask as 999G999G999G999G990D0000 in the Number Field.

Akil_Ramesh
  • 391
  • 3
  • 9