繁体   English   中英

if 语句检查用户是否将文本框留空 - 问题

[英]if statement to check if the user has left the text box empty - issue

我有一个带有文本框的 Web 表单,用户可以在其中输入 URL,因此默认情况下我输入了 https:// 但如果用户之后没有输入 URL 并将其留空,我想显示错误。 我用过了

if (textBox1.TextLength <= 9)
{
    // code
}

而不是Length检查,使用具有.Text属性的相等运算符来检查文本框中的确切文本。

//This means, there is only "https://" is written in the text box
if(textBox1.Text == "https://")
{
   //Show an error. Here user did not enter anything
}
else
{
    //Your implementation
} 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM