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

Question

Question

How to Remove ',' From Number Fields?

asked on November 4, 2014

In Forms 9.2 I have noticed that number fields automatically add a ',' to the values in them. Is there a way to change this? We have number fields that are used for zip codes and having a ',' in the zip code is not ideal.

1 0

Answer

APPROVED ANSWER SELECTED ANSWER
replied on November 4, 2014 Show version history

Since this is IE specific behavior, you can workaround this by using the following javascript to remove commas from the input. Note that my number field is using a class called zip.

$(document).ready(function() {
  $('.zip input').on('change lookup', function() {
    var tValue = $(this).val();
    tValue = tValue ? parseFloat(tValue.replace(/,/g, '')) : '';
    $('.zip input').val(tValue);
  });
});
1 0

Replies

replied on November 4, 2014

Was the form created in a previous version? I created a new form in 9.2 and when entering a 5-digit number into a number field, I don't have any commas automatically inserted (either in the form fields upon submission or when mapping the form fields to Laserfiche fields). Can you clarify where you're seeing the commas? Is there any CSS or JS involved? It may be best to open a support case with your reseller and provide a copy of the business process/form so it can be investigated.

0 0
replied on November 4, 2014

Yes, the form was created in a previous version. We have a database lookup happening to populate the number field. In the database there is no comma, but once it is pulled and put into the field, the comma shows up as so 83,401. With that field there is no CSS or JavaScript involved.

1 0
replied on November 4, 2014

What is the column type in the database table the values are being pulled from?

0 0
replied on November 4, 2014

nchar(10)

1 0
replied on November 4, 2014

The issue still can't be recreated so we'll need to investigate further. Are you only seeing the issue occur from a lookup or does it also occur in number fields where submitters are manually entering a number? In any case, please open a support case with your reseller.

0 0
replied on November 4, 2014

This happens with a lookup and if someone manually types something into the field. I have opened a support case with our reseller.

1 0
replied on November 4, 2014

Sounds good. In the meantime, here's a video of how I tried to recreate the issue, but wasn't able to. Perhaps if you're doing something different than what I did in the video, you can indicate that as it would help is in figuring out the cause of what you're running into.

Screencast Video

replied on November 4, 2014 Show version history

Sounds good. In the meantime, here's a video showing how I tried to recreate the issue, but couldn't. If I'm doing something differently than you are, please let me know as that may help in determining the cause of what you're running into.

Screencast Video

0 0
replied on November 4, 2014

One thing that is different is that we are passing a querystring value to forms to fill in one text field. The lookup is then done based on the value from that text field. I'm not sure if that would make a difference or not. Also, the number field is set to required.

1 0
replied on November 4, 2014

It seems this is an issue with using IE. When you select the field and view it in IE's debugger, you'll see that the standard number input is being replaced with something like

<input class="ws-number ws-inputreplace number cf-small hide-inputbtns user-success" role="spinbutton" aria-invalid="false" aria-required="true" aria-labelledby="" style="margin-right: 0px; margin-left: 0px;" type="text" placeholder="" value="" inputmode="numeric" autocomplete="off">

Chrome and Firefox don't do this. We'll look into this and see what can be done for IE.

2 0
APPROVED ANSWER SELECTED ANSWER
replied on November 4, 2014 Show version history

Since this is IE specific behavior, you can workaround this by using the following javascript to remove commas from the input. Note that my number field is using a class called zip.

$(document).ready(function() {
  $('.zip input').on('change lookup', function() {
    var tValue = $(this).val();
    tValue = tValue ? parseFloat(tValue.replace(/,/g, '')) : '';
    $('.zip input').val(tValue);
  });
});
1 0
replied on January 6, 2015

Alex,

I have a similar request, but the opposite.  I am looking for a way to format input fields as comma separated numbers (1,234 or 123,456).  Is this possible with CSS or does it require more javascripting?  

Thanks,

Nate

0 0
replied on January 6, 2015

You can use this javascript. Note that your input field will need to use the CSS class "comma" and that this will also account for decimals.

$(document).ready(function() {
  $('.comma input').on('change', function() {
   var tValue = $(this).val().split(".");
   tValue[0] = tValue[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
   $('.comma input').val(tValue.join("."));
 });
});

 

0 0
replied on November 6, 2014

Hi Blake, 

If your question has been answered, please let us know by clicking the "Mark this reply as the answer" button on the appropriate response.

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

0 0
replied on November 6, 2014

It has not been fully answered yet. I am waiting to see if development thinks that they will be able to fix this in a future update.

1 0
replied on November 6, 2014

This might be looked into as an option in a future version, but since it only impacts IE and not other browsers, using Javascript is the best way to handle it now.

0 0
replied on November 28, 2014

The Java Script provided is only for a number field that is being looked up, what do I do for a field that is input by the user?

0 0
replied on December 1, 2014

For a minute there I thought you were my sister. I really do have a sister with the same name. I believe you would just take out the word lookup from the jQuery. I have not tested it though.

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

Sign in to reply to this post.