views:

36

answers:

1

I don't get it; this should be simple:

Why does this text box entry:

Foo 2010

Validated by this REGEX:

ValidationExpression="^[a-zA-Z0-9 -_!]+$"

Throw an invalid entry error? It is intended to allow alphamumerics, spaces, dashes, underscores and exclamation marks.

REGEX gives me a headache ...

+3  A: 

The dash - should be placed right after [ or placed before ] or escaped with \,
otherwise it'll be treated as a class range metacharacter.

Try this: ValidationExpression="^[-a-zA-Z0-9 _!]+$"

Nick D
Or he could add a `\-`
BrunoLM
@BrunoLM, yes thanks. I updated my answer.
Nick D
Thanks Nick! Thanks Bruno! Worked great.
GDB