Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Number formatting help

Questions related to using nuBuilder Forte.
Post Reply
orangezero
Posts: 22
Joined: Fri Jan 03, 2020 7:08 pm

Number formatting help

Unread post by orangezero »

I have a slightly unique situation I'm trying to figure out. I need people to input numbers quickly, but still save in the correct format. Let me give a few examples to illustrate:

user types "2" and then it auto formats to "+2.00"
user types "-2" and then it auto formats to "-2.00"
user types "1.5" and it auto formats to "+1.50"

I see where to specify decimal point and # of zeros in nubuilder, but I'm not sure about adding the + or - automatically in a format the software understands. I can get it to add +/- easily enough in front of a number... just not be selective depending on what is typed in.

One option I thought to save time was to separate the + and - into a new area that users would select before each number, but I hope there is a simpler way.

An alternative would be to have a drop down of available numbers to pick from and just have -2.00 and +2.00 in that list also, but I haven't figured out if typing or selecting from a list is going to be easier for users. I'm open to advice on this. I just have my past experience as a user thinking the option I'm not using must be faster, ha.

Thank you for even reading all this...
kev1n
nuBuilder Team
Posts: 4288
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 442 times
Contact:

Re: Number formatting help

Unread post by kev1n »

You'd have to use a Text format for "Input Type (and class)" and in the database a varchar column type in order to have a "+" sign stored in the database.

Adding an onblur JavaScript event to the object's Custom Code will format the number accordingly when the field loses focus.

Code: Select all

let v = $(this).val();
let num = parseFloat($(this).val());
let fixed = num.toFixed(2);
fixed = fixed > 0 ? '+' + fixed : fixed;
$(this).val(fixed).change();
You do not have the required permissions to view the files attached to this post.
orangezero
Posts: 22
Joined: Fri Jan 03, 2020 7:08 pm

Re: Number formatting help

Unread post by orangezero »

Your speed is most impressive! Many thanks to you and the others who have took up the nuBuilder mantle.
kev1n
nuBuilder Team
Posts: 4288
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 442 times
Contact:

Re: Number formatting help

Unread post by kev1n »

Thanks orangezero , you are the most welcome!
Post Reply