Requiring Number Validation for Constant Sum Matrix Table | XM Community
Skip to main content

Hello! I am working with a constant sum matrix table where respondents input a number that is 0-100 at each column-row intersection and each column totals to 100 at the bottom. Is there a way to further limit them so that they may only input numbers that are increments of 5? E.g., instead of being able to give a 47%, 53% split, they are required to give a 45%, 55% split?

 

One of the way is to use JS to check number entered on blur event if divisible by 5.

OR we can also use match regex custom validation for each text entry box using below regex:

^[0-9]*[05]$

 


One of the way is to use JS to check number entered on blur event if divisible by 5.

OR we can also use match regex custom validation for each text entry box using below regex:

^[0-9]*[05]$

 

Thank you! Do you know what the JS code would be? There are 170 text entry boxes so i think the regex match would be too manual @Shashi 


One of the way is to use JS to check number entered on blur event if divisible by 5.

OR we can also use match regex custom validation for each text entry box using below regex:

^[0-9]*[05]$

 

Thank you! Do you know what the JS code would be? There are 170 text entry boxes so i think the regex match would be too manual @Shashi 

Try this:

jQuery("#"+this.questionId+" inputptype='text']").on('blur',function(){
if(jQuery(this).val()%5!=0){
jQuery(this).val('').focus();
alert("Number should be divisible by 5");
}
});

 


One of the way is to use JS to check number entered on blur event if divisible by 5.

OR we can also use match regex custom validation for each text entry box using below regex:

^[0-9]*[05]$

 

Thank you! Do you know what the JS code would be? There are 170 text entry boxes so i think the regex match would be too manual @Shashi 

Try this:

jQuery("#"+this.questionId+" inputptype='text']").on('blur',function(){
if(jQuery(this).val()%5!=0){
jQuery(this).val('').focus();
alert("Number should be divisible by 5");
}
});

 

@Shashi Hmm this didn’t work


@Shashi Hmm this didn’t work

Please check if the code is pasted in correct function.


Leave a Reply