InputText attributes for textual Matrix Table | XM Community
Solved

InputText attributes for textual Matrix Table

  • 8 April 2019
  • 6 replies
  • 49 views

Badge +1
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
icon

Best answer by Anonymous 8 April 2019, 01:36

View original

6 replies

Badge +1
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, ''); });
Badge +1
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 ?
Badge +1
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!
Badge +1
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