Formatting Negative Numbers

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
customaware
Posts: 2391
Joined: Mon Jul 02, 2012 12:24 am
Location: Ulaanbaatar, Mongolia

Formatting Negative Numbers

Post by customaware »

On a BO Form, I want the user to be able to enter a negative number of the form...

-1,234.56 and then as the user Tabs away from the field or saves the form, I want it to display as (1,234.56)
Also want it to display in a Query as (1,234.56)

Does anyone know of a way to achieve that please?
Cheers,
Mark
_________________
AwareIM 6.0, 8.7, 8.8, 9.0 , MariaDB, Windows 10, Ubuntu Linux. Theme: Default, Browser: Arc
Upcloud, Obsidian....
Image
idpSteve
Posts: 201
Joined: Thu Jul 27, 2017 6:13 am
Location: Johannesburg, South Africa
Contact:

Re: Formatting Negative Numbers

Post by idpSteve »

I think you can try something like

#;(#)

for the number format. I remember getting some errors around this, I don't remember what worked but I think that's part of the fix! Let me know..
customaware
Posts: 2391
Joined: Mon Jul 02, 2012 12:24 am
Location: Ulaanbaatar, Mongolia

Re: Formatting Negative Numbers

Post by customaware »

Tried that but it did not work
Cheers,
Mark
_________________
AwareIM 6.0, 8.7, 8.8, 9.0 , MariaDB, Windows 10, Ubuntu Linux. Theme: Default, Browser: Arc
Upcloud, Obsidian....
Image
BLOMASKY
Posts: 1470
Joined: Wed Sep 30, 2015 10:08 pm
Location: Ocala FL

Re: Formatting Negative Numbers

Post by BLOMASKY »

I know with HTML you can have <<BO.attr @ ###,###;(###,###)>>

but you want to do this with the actual attribute format. Not sure if you can do that.

Of course, for the query, you could have a plain text field that is updated when the actual field changes and is formatted properly, but that won't solve the problem of the user tabbing out of the field. I am not sure if you would get stuck in an endless loop, but could you have the following javascript in your form render script:

var cq = parser.getField("customerQty");

$("#" + cq.getId ()).focusout (function () {
if (cq.getValue() != cq.originalValue && cq.getValue() < 0)
cq.setValue('(' + cq.getValue() + ')');
});
Post Reply