I want to validate, that for certain answers in multiple form fields, only positive integer numbers can be entered AND that the values can be between 1 and 300
Solved
Javascript code to validate numeric integer only
Best answer by qualtrics_nerd
Hi
I was able to find a JS solution for your query using regex provided by
Qualtrics.SurveyEngine.addOnload(function()
{
/*Place your JavaScript here to run when the page loads*/
});
Qualtrics.SurveyEngine.addOnReady(function()
{
let regex = /^(?:[1-9]|[1-9][0-9]|[12][0-9]{2}|300)$/;
jQuery("#"+this.questionId+" input").on('input', function() {
if (regex.test(jQuery(this).val())) {
jQuery('#NextButton').show();
} else {
jQuery('#NextButton').hide();
}
});
});
Qualtrics.SurveyEngine.addOnUnload(function()
{
/*Place your JavaScript here to run when the page is unloaded*/
});
This code hides the "Next” button if regex does not mtaches.
Hope this resolves your query😊!!
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.





