tags:

views:

14

answers:

1

Hi Everybody, I want confirm button extender to pop up when Particular TextBox is empty. How to do that? Thanks in advance. Any help would be appreciated.

A: 

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();" />
Aristos