我有一個帶有文本框的 Web 表單,用戶可以在其中輸入 URL,因此默認情況下我輸入了 https:// 但如果用戶之后沒有輸入 URL 并將其留空,我想顯示錯誤。我用過了
if (textBox1.TextLength <= 9)
{
// code
}
但如果用戶嘗試輸入 ftp URL,這將不起作用。
我如何更改我的 if 陳述句以檢查用戶是否將文本框留空,除了默認的 https://
uj5u.com熱心網友回復:
而不是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
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/316391.html
上一篇:繞過App檢測抓包
