Formatting answer fields with comma separator and auto-sum | XM Community
Skip to main content
We are encountering some issues in validating the formatting we have set for our fields. In fact, we have managed to put the formatting ( the ',' as the thousands separator) however there is an alert that appears stating "Exclude commas and, if necessary, use a full-stop as a decimal separator" and does not accept the input.



Consequently we do not manage to submit the results and carry forward in the email. Is it possible to eliminate this alert and remove it?
@fabioruffinoni,



Where are you seeing this error? In a survey question? When you add commas to a number, it becomes a string and is no longer treated as a number. That is probably the root cause of your issue.



See:

https://www.qualtrics.com/community/discussion/comment/2906#Comment_2906
@TomG,



Yes, we are seeing this issue associated to a survey question, in particular with matrix questions with the constant sum feature.

We have saw the discussion and followed it and what we want to achieve is exactly the same as the example provided (https://marketinview.ca1.qualtrics.com/jfe/preview/SV_5BJQep47RoVm9Rr?Q_SurveyVersionID=current&Q_CHL=preview) but we seem not to manage.



Below is the code we inserted with the components associated to the formatting of it and here is the link to the survey, when inserting a number is an editable field, it does not allow you to then proceed with the survey: https://pwcitaly.eu.qualtrics.com/jfe/form/SV_3f66Yc39ih6n7cV



Do you see the mistake or know what the issue could be?



Thanks,

Fabio



_Custom code_

<script src="https://cdn.jsdelivr.net/npm/cleave.js@1/dist/cleave.min.js"></script>

<script>

var inputs = jQuery("input[type='text']");

inputs.attr('maxlength','11');

inputs

.toArray()

.forEach(function(field) {

new Cleave(field, {

numeral: true,

numeralThousandsGroupStyle: 'thousand',

});

});

</script>
@fabioruffinoni,



As I mentioned in my earlier post, once you add commas to a numeric field, it becomes a string instead of a number. At that point you can't do any numeric validation on it. When you format numbers with cleave you are changing them to strings.



In the example I posted, I hid the original constant sum fields and replaced them with new inputs that cleave is attached to. JS then keeps the new inputs the original hidden inputs in sync.

Leave a Reply