You are viewing limited content. For full access, please sign in.

Question

Question

Currency Field formatting

asked on August 13, 2014

Hi,

 

I have a need for currency field formatting. I have seen this post here that discusses how to do this. However, I am doing calculations and I wish to stick with the currency field as opposed to using a Single Line field. I also need to post the value of these fields into a SQL table with decimal datatypes.

 

I would like to have forms allow you more options for field formatting for currency. The same way you have to the options in the Laserfiche Field editor for field formatting. Currently, date fields in Forms have some formatting options, but not Currency fields.

 

The specific requirement is to choose a thousands separator and limit how many decimal places it must round off to.

 

If there's a workaround for now, please let me know, I could really use it.

 

Thanks guys!

Sheldon

1 0

Answer

APPROVED ANSWER
replied on August 13, 2014

Thanks for the feature request! This is definitely something we'd like to improve in the future. The solution to the post you mentioned includes the currency symbol with the value, which you probably don't want.

 

As for a workaround, you can try this JavaScript. As written, it formats the value for a currency field as soon as the value is entered. It's up to you to decide when you want to format the numbers you're working with, but this code should give you a good start.

 

$(document).ready(function() {

  $('input.currency').change(function() {
    $(this).val(formatCurrency($(this).val()));
  });
  
  function formatCurrency(value) {
    var float = parseFloat(value);
    return isNaN(float) ? 0 : (Math.round(float*100)/100).toFixed(2);
  }
});

 

0 0
replied on August 21, 2014

I just wanted to vote for this as a feature request as well! I have some customers interested in this too. Thanks!

3 0

Replies

replied on August 15, 2014

Hi Sheldon, 

 

If your question has been answered, please let us know by clicking the "This answered my question" button on the response.

 

If you still need assistance with this matter, just update this thread. Thanks!

replied on August 28, 2014

I have a table where I used the code above. However, I had two columns that I made Read Only. 

So when it calculates the tables together, it will total in a currency field. However, it rounds the number and does not include the decimals. Ex: It will total 700.15, but in the currency field, only displays 700.  

 

 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.