Solved
Allow only integer as an answer (via JavaScript?)
Hi there!
I want to validate, that for certain answers, only integer numbers can be entered (i.e., only 6 or 7 and not 6.4 or 7,3).
I found this java code quiet handy:
jQuery("#"+this.questionId+" .InputText").attr({'type':'number','min':'0'});
(I found it here: https://www.qualtrics.com/community/discussion/1125/how-to-set-a-field-to-number-only )
Unfortunately, it still allows floating numbers and even minuses. It seems, that 'type' cant simply changed from 'number' to 'integer' (I am not really into JavaScript).
May anyone help me? I already have a workaround using custom validation and RegEx code (^\\d*$) but for some reason, this custom validation doesn't react in a "Form"-Question. Nevertheless, I also prefer the Java-solution, which from the beginning prohibits entering text and allows only numbers (and also "," and "." ¯\\_(ツ)_/¯ )
Happy for any suggestions!
Best answer by TomG
```
jQuery("#"+this.questionId+" .InputText").on("input", function() {
this.value = this.value.replace(/[^0-9]/g,"");
});
```
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.

This is where I pasted the code.
Like this? Qualtrics is giving me an error signal...
