iT邦幫忙

0

Visual C# 請問MessageBox.Show需要宣告嗎?

問題一:請問MessageBox.Show需要宣告嗎?
因為我直接Key會出現錯誤訊息。
問題二:請問TextBox判斷輸入是否空白,需要如何撰寫程式,因為 TextBox不只一個,麻煩請協助,謝謝~!![https://ithelp.ithome.com.tw/upload/images/20171026/20107022GFwfLvyeHV.jpg

2. if(textBox1.Text==""){} if(textBox2.Text==""){}
同時判斷就依照你的需求使用AND或是OR
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
baida0630
iT邦新手 4 級 ‧ 2017-10-27 10:25:49
最佳解答

第一個問題 請看 這邊

第二個問題 要看你想要怎麼做,如果量大我建議還是用Jquery對Class做判斷來達到範圍判斷

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $(".bt").click(function(){
    $(".tb").each(function() {
   if($(this).val() == "" || $(this).val() == null)
        {
        	var tb = $(this).attr("tbn");
        	alert("textbox" + tb + "不得為空");
        }
    });
    	
    });
});
</script>
</head>
<body>
<button type="button" class="bt"></button>
 <input type="text" class="tb" tbn="1">
 <input type="text" class="tb" tbn="2">
 <input type="text" class="tb" tbn="3">

</body>
</html>

我要發表回答

立即登入回答