Regex validation not working | XM Community
Skip to main content

Hi everyone, I am asking participants in an anonymous survey to enter a password. I would like it to:

  • be at least 8 characters long;

  • include at least one digit;

  • include at least one lowercase letter;

  • include at least one uppercase letter.

The regex code I am using is:
(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.{8,})
However when I test it, passwords that only respect two constraints are validated, e.g. 1234567a or 1234567A. What am I doing wrong?
Thanks for your help!

I don't think the regex engine used by Qualtrics supports lookahead or lookbehind.


https://community.qualtrics.com/XMcommunity/discussion/comment/55636#Comment_55636thanks Tom - but where do I have those? I am a beginner, but still I do not think I have lookahead or lookbehind in that formula, though perhaps I am not understanding what you mean...


?=
is a lookahead.


ah, I see! It is still weird that it seems to work with two constraints, but not all of them. I'll try and rework the conditions, thank you.


I think you'll need to use JavaScript to do the password checking and have it update a hidden question that you can use in your Custom Validation.


thanks Tom - unfortunately I've got no idea of how to do that. I'll keep digging, thanks so much for the pointers!


Leave a Reply