Solved
Regex validation questions with strings and numbers
Hello,
Our group is developing surveys for a large study, and we give each participant an ID number. For new participants, the format is "AJA-XXXX" where the X's are digits 0-9. For visiting participants, the format is "AJA-XXXX.X." Here are some ID numbers that fit:
> * 1. AJA-2001
> * 2. AJA-2163
> * 3. AJA-2003.1
> * 4. AJA-2002.2
>
However, we don't want the following:
> * aja-2002 (first part not capitalized)
> * AJA3012 (no dash)
> * AJA-2009. (a period, but no digit afterwards)
> * AJA-1008.01 (two digits after the period)
>
After some googling, I came up with ``[T][R][T]\\-\\d{4}[\\.]?[\\d{1}]?`` but it didn't work :/
I would be extremely grateful for any help or suggestions. Thanks!
Best answer by TomG
Try this regex:
^AJA\\-[0-9]{4}(\\.[0-9])?$
One issue is that Qualtrics regex validation is case insensitive. So, you'll have to use JavaScript to convert to upper case.
```
Qualtrics.SurveyEngine.addOnload(function() {
jQuery("#"+this.questionId+" .InputText").on('blur', function() {
this.value = this.value.toUpperCase();
});
});
```
View originalLeave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.