2010-09-22 36 views

回答

0

這裏有一個簡單的方法

<script>  
function CheckEmptyBox() 
{ 
    var TextBox = document.getElementById("<%=TextBox1.ClientID%>"); 

    if("" == TextBox.value) 
    { 
     return confirm("text box is empty - ok to continue ?"); 
    } 
    else 
    { 
     return true; 
    } 
} 
</script> 

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" OnClientClick="return CheckEmptyBox();" /> 
相關問題