C# checking white space in a textbox

后端 未结 9 1071
孤独总比滥情好
孤独总比滥情好 2021-01-03 06:45

How can I check in C# that is there a white space only in a textbox and perform some operation after that?

9条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-03 07:05

    //SIMPLE WAY TO VALIDATE EMPTY SPACES
    if (txtusername.Text.Contains(" "))
    {
        MessageBox.Show("Invalid Username");
        txtusername.Clear();
        txtusername.Focus();
    }
    

提交回复
热议问题