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

Question

Question

negative number in currency field?

asked on December 8, 2015 • Show version history

is it possible to enable negative numbers for the currency field?  I am looking to use this field as a positive or negative number for other adjustments.

 

0 0

Replies

replied on December 8, 2015

Works for me. Make sure you don't have some custom javascript validating the field.

0 0
replied on December 8, 2015 • Show version history

Chris,

thanks for the suggestion, as I do have a jquery to automatically add commas after every 3 digits.  Is there a workaround to have both working?

 

 $('.currency input, .table1c1 input, .table1c2 input, .table1c3 input').attr("pattern", '^(\\d+|\\d{1,3}(,\\d{3})*)(\\.\\d{2})?$');
  
  $('.currency input, .table1c1 input, .table1c2 input, .table1c3 input').on("change", function () {
    $(this).val($(this).val().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,"));
  });

 

0 0
replied on December 8, 2015

Hi Tommy,

You should be able to accomplish that by simply allowing for a minus symbol in the regular expression.

So line 1 in your code becomes

$('.currency input, .table1c1 input, .table1c2 input, .table1c3 input').attr("pattern", '^([-]?\\d+|[-]?\\d{1,3}(,\\d{3})*)(\\.\\d{2})?$');

And that should do the trick. Hope this helps!

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

Sign in to reply to this post.