Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Select Question: Other Specify Option with only Letters, no numbers !

Hello everyone,

hope you are doing well!

I have a very similar question like Mauricio (see related question).

I have a standard single select question type, where it has a Respondent specify ("Other Specify") option. Currently, the textbox accepts all kinds of values. However, I would like to configure the textbox to accept only letters (from A-Z), and e.g., No figures.  

 Zachary showed in  the related question (many thanks for this), that I need to use Custom Javascript Verification. But since I am not an JavaScript ninja, I would very much appreciate your help for this question.

I guess I can take this script:
var resp = SSI_GetValue('[% QuestionName() %]_3_other');
var regex = /[0-9]+/;
if (resp && !regex.test(resp)) {
    strErrorMessage = 'Error.';
}
would  need to change: var regex = /[0-9]+/; to something else?

Or do you see any other option?

Many thanks in advance!
Regards from Austria,
Alfons
asked Feb 7 by Alfons
Give this a try. I'm not an expert with regular expressions but thought this might do the job?

Replace:
var regex = /[0-9]+/;

With:
var regex =/[a-zA-Z]+/;

Also change your "_3_other" to the appropriate code number.

Let me know how you go.
Hi Paul! Many thanks - it works!! Very much appreciate your comment!

1 Answer

0 votes
Well done. Thanks for letting me know.
answered Feb 9 by Paul Moon Platinum (58,815 points)
...