Quote Originally Posted by selanec
If it's not required field then why you use the RequiredFieldValidator?
By default, RequiredFieldValidator allows you to enter spaces but it always throws an exception/error after validating. Maybe you want to use CustomValidator for the purpose? In addition if you want to dissalow the users of entering spaces entirely you can use javascript to find if space bar was pressed!

if (window.event.keyCode == 32) {
//Space
return false;
}
I said I was using the RegularExpressionValidator not the RequiredFieldValidator. I need to know if there is a way to override the behavior of RegularExpressionValidator so validation fails on empty spaces. I'm guessing no.

So everywhere I have a RegularExpressionValidator on a non-required field the I have to manually check if spaces are entered:

Code:
if(string.IsNullOrEmpty(TextBox.Text.Trim())) {
}
so I won't save spaces in my database.

The javascript hack you wrote to check for spaces isn't an option.