This content has been marked as final. Show 2 replies
> I have a "UserID" field that can't have spaces or backslashes in it. I've put
> together the following reg ex but it doesn't seem to work and I'm not sure why.
> In other words, even if I type "jdoe$" (which does not have a space or
> backslash) I still get the pop-up from my cfinput. Can someone please shed some
> <cfinput type="text" name="UserID" size="45" required="yes" message="Please
> make sure the UserID does not have spaces or backslahes."
> validate="regular_expression" pattern="[[:space:]\\]">
Your regex pattern here has to match what you DO want, not what you don't
want. I'm also not sure JS regexes support posix-styled character classes.
I suspect you haven't thought through your requirement here. In saying
simply that the userid can't have spaces or backslashes (and approaching
the regex that way), you're implying that *any other character* is OK.
So this userid would be just fine: !"£$%^&*()_-+=. I has no spaces or
backslashes in it.
The pattern needs to match what's valid, not what's invalid.
"The validation succeeds only if the user input matches the pattern."
This will match any strings that don't contain whitespace (spaces, tabs, form feeds, line feeds) and don't contain a backslash.