Text box validation not working

前端 未结 7 1404
[愿得一人]
[愿得一人] 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:57

    What about:

    if (txtFirstName.Text.Contains(" "))
    {
        txtFirstName.BackColor = System.Drawing.Color.Yellow;
        lblError.Text += "Please enter first name without blanks
    "; }

提交回复
热议问题