Confirm button extender if textbox is empty
I want confirm button extender to pop up when Particular TextBox is empty. How to do tha开发者_运维知识库t? Thanks in advance. Any help would be appreciated.
Here is a simple way
<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>
and
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" OnClientClick="return CheckEmptyBox();" />
精彩评论