Issues with commas in a dollar value text field | XM Community
Skip to main content

I apologize if someone’s already asked about this and I couldn’t find a similar posting or answer.

 

I’ve got a budget form where I’m asking individuals to enter dollar amounts. 

Originally I didn’t include the text about not including commas (I’ve since added it in hopes of preventing any other issues before the deadline to submit, but I can manually fix on the back end), because I thought I’d tested it and it worked fine, but I ran into some issues with the totals not calculating in my embedded data because of the few instances when folks included commas in the Total cost field dollar amount. 

 

This is how I’m calculating the total across 4 pages like the screenshot above. I did try another addition calculation previously that I’d found here on the Community and this one seemed to work more reliably when I had empty values since not every person is going to need to budget for 20 individuals.

 

So I’m curious if there’s something I can do to either A) make commas included still work in the calculation or 😎 strip any commas included to ensure the math calculates correctly. 

Thanks!

Hi @courtrc , I think there’s another option for you
C) Force respondent to type in number only by using validation

Hope this helps


@Nam Nguyen unfortunately, I did already have that Numeric Value field validation set and apparently they were still able to enter the comma which led to the issues. But thanks for the idea!


@Nam Nguyen unfortunately, I did already have that Numeric Value field validation set and apparently they were still able to enter the comma which led to the issues. But thanks for the idea!

@courtrc My bad, I’ve just test it. Apparently, comma and point are still part of that default Numeric Value to represent decimal point.
Instead, you can use custom validation by matching regex code “^\d+$”. This will only let number digit get through.

 


@courtrc,

I generally use cleave.js for these type of inputs so the numbers are automatically formatted as currency on entry, then saved as raw values on submit.

A couple of simpler solutions:

  1. Use JS to change the input types to number, which would prevent non-numbers from being entered
  2. Use a JS input handler to only allow input of numbers

@Nam Nguyen thanks for the suggestion!

 

@TomG I’ll look into this. Thanks for the recommendation!


Leave a Reply