Fog Creek Software
Discussion Board




Welcome! and rules

Joel on Software

ASP .NET validator

The regular expressions field validator in ASP .NET has a problem:


Let's say I give it this regular expression:

[^ ]+

In human language: [not space] match_1_or_more_times


That is, this expression should validate the field ONLY if it contains a string who's length is NOT zero, and which doesn't contain spaces.

But.. it doesn't work that way.


If I enter nothing (the null string), or I enter just spaces, the validator doesn't complain at all.

It seems that in these situations, the validator isn't even fired...

Mike
Tuesday, November 25, 2003

You need to use the RequiredFieldValidator for this scenario. Often controls will need a RegexValidator AND a RequiredFieldValidator.

Duncan Smart
Tuesday, November 25, 2003

*  Recent Topics

*  Fog Creek Home