开发者

Confirm button extender if textbox is empty

开发者 https://www.devze.com 2023-01-16 22:41 出处:网络
I want confirm button extender to pop up when Particular TextBox is empty. How to do tha开发者_运维知识库t?

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

精彩评论

暂无评论...
验证码 换一张
取 消