开发者

Validating an ASP.Net textbox as not empty but allowing whitespace?

I have an ASP.Net 2.0 textbox which I need to be validated as having some content, but where whitespace alone is valid input.

A required field validator seems to reject a pure whitespace input as inval开发者_如何学Pythonid. A regular expression validator won't fire at all on empty content.

Is there a simpler way round this than using a custom validator control?


There are a couple of options, neither which use the automagic FUD.

  1. Create a new type of validator that does not Trim() prior to validation - this is the long pole and most time consuming
  2. Use JavaScript to validate and control the postback yourself (assuming client validation)
  3. Server side validate (or use AJAX for validation) - Potential negative is waiting to validate until a postback

I can't think of any other options.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜