Is there a way to format a number in input field?

Is there a way to format a number in input field?

  

I have an input field and I'd like to format the number written by the end user with two decimal places and setting a group separator with a space. I cannot use the formatdecimal built-in function as it does not work in the input field. Customs Masks do not work in this environment - it did not install at all. Using input masks trigger some unusual events that are not desired. Any hints? Thanks.


Hi Jorge,

What is your platform version?


Regards,
Thomas

VERSION 9.1.300.0

Jorge,

Supposely, the CustomMasks component should work on that version. Why can't you use it in your environment?

Regards,
Thomas

It is not working. It stays in this way all the time... 

Hi Jorge,

we can use jquery like below:

SyntaxEditor Code Snippet

function formatCurrency(total) {
    var neg = false;
    if(total < 0) {
        neg = true;
        total = Math.abs(total);
    }
    return (neg ? "-$" : '$') + parseFloat(total, 10).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, "$1,").toString();
}

function PriceOnBlur(obj){
 debugger;
 $(obj).val(formatCurrency($(obj).val()))
}


Regards

SK

thanks. I will need a jquery script to allow numbers and dot...

Jorge,

I have implemented same feature using provided jquery script.

you can use it.

Regards

SK


Solution

Jorge Almeida wrote:

It is not working. It stays in this way all the time... 

Hi Jorge, 


Do you have multiple catalog in your database?

If you have, you cannot install via service studio.

Please, try to install the Custom Masks component via Service Center.


Let me know if it solved your issue.

Thanks.


Solution

Dear Nuno


It worked uploading from the service center! Thanks for the tip. 

You're welcome, Jorge. :)

Best regards.