InputText attributes for textual Matrix Table | XM Community
Skip to main content
Have a matrix table for text entry that is 2x2 for entering results of testing 2 samples 2 times. Many users will be using mobile devices so we want to set the InputText attribute to 'number'.



For a single text entry the code (thanks to TomG) is:

jQuery("#"+this.questionId+" .InputText").attr('type', 'number');



This does not work for the 2x2 MT.



Have tried the following with all 4 of the addresses enumerated (1~2, 2~1, 2~2):

jQuery("#"+this.questionId+"#1~1"+" .InputText").attr('type', 'number');

jQuery("#"+this.questionId+"~1~1"+" .InputText").attr('type', 'number');



Been searching for about 4 hours without finding anything.



thanks
Forgot this link to the original answer:

https://www.qualtrics.com/community/discussion/1125/how-to-set-a-field-to-number-only
Hello @WaterSampler ,



Use the below code:



var input = jQuery("#"+this.questionId+" input[type='text']");

input.attr('type', 'number');

input.on('input', function() { this.value = this.value.replace(/e/g, ''); });
Almost @Shashi. The keypad is now numeric and shows a decimal point but the decimal cannot be entered. Our values are entered in tenths (e.g., 10.5).



Many thanks.
> @WaterSampler said:

> Almost @Shashi. The keypad is now numeric and shows a decimal point but the decimal cannot be entered. Our values are entered in tenths (e.g., 10.5).

>

> Many thanks.



I tested this, and it allows decimals. Are you using Safari ? On which browser are you testing ?
Tried on an android phone with firefox. Firefox was put on because default google browser did not work with earlier tests. Decimal problem is with Firefox.



Many thanks again!
Update.



The decimal functionality is browser dependent. A fix was to modify the @Shashi code to:

var input = jQuery("#"+this.questionId+" input[type='text', step='0.1']");

Leave a Reply