I am trying to limit the number of characters (2,500) or words (350) in a multiple choice question that allows text entry (e.g., other please specify response).
I know I have 2 options: a) custom validation using regex or b) javascript. I tried the following regex but it did not work.
^(?:\\b\\w+\\b*){1,350}$
Anything longer than 1 line in the text box gets flagged. Below you'll see an example I used that should not have been flagged and it was.
Any suggestions?
Hi smgreenPhD Can you try the below JS and let me know if this works out for you?
Qualtrics.SurveyEngine.addOnload(function()
{
jQuery("#"+this.questionId+" .InputText").each(function () {
jQuery(this).attr('maxlength','19');
});
});
@Aanurag_QC No, the JS did not work. It allowed me to input 3000 words with no issue.
Hi smgreenPhD Can you please clear the Javascript and paste this again. For me, it works fine.
@Aanurag_QC I edited the question javascript. See pic. Am I putting the Javascript in the right location?
In survey preview I added 1,000 word text and it submit fine without any limitation. It should not do that.
smgreenPhD For me its not allowing more than 19 characters using the same JS:
I placed it within the question and not in the header of the survey
I was actually able to figure out a regex solution before I saw your latest response.
For regex, I used this:
^\\W*(?:\\w+\\b\\W*){0,350}$
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.