tags:

views:

508

answers:

2

Is there an easy way of using the RegularExpressionValidator control while ignoring white space?

I can use a custom validator control with Regex and IgnorePatternWhitespace, but it would be good to just have an option in the RegularExpressionValidator control.

A: 

Remember that the regular expression validator want to validate with javascript, too, so you want to make sure your expression will work with both the .Net and javascript regex engines. That means that using .IgnorePatterWhitespace isn't the best idea.

Joel Coehoorn
But, you can set EnableClientScript to false and then it's not an issue.
sectrean
+1  A: 

Surround your regex with

(?x: )

so "a b c" becomes "(?x:a b c)

Will