Text box validation not working

前端 未结 7 1438
[愿得一人]
[愿得一人] 2020-12-12 07:40

Right now the code below tests for a blank text box. If it is blank it returns the error stated below the if statement. That works fine, but I also want it to check for wh

7条回答
  •  情深已故
    2020-12-12 07:52

    You should check the manual:

    http://msdn.microsoft.com/en-us/library/system.string.isnullorwhitespace.aspx

    Indicates whether a specified string is null, empty, or consists only of white-space characters.

    So use another function if you don't want any spaces (or other whitespace) to be present, like Contains or using a RegEx.

提交回复
热议问题