if this is your textbox markup:
<asp:textbox id="txtInput" runat="server" />
and then this is the button that activates the confirmation:
<asp:button id="btnSumbit" runat="server" onclientclick="return clearOnConfirm();" text="Submit" />
then you will need the following javascript:
<script type="text/javascript"> function clearOnConfirm() { if (confirm("Are you sure you want to continue?")) { document.getElementById("<%=txtInput.ClientID %>").value = ''; return true; } else { return false; } } </script>
If all you want to do is clear the text box, but always continue to transmit, then you do not need to return false as above, but always return true, as shown below. In this case, you must rethink the message displayed to the user.
<script type="text/javascript"> function clearOnConfirm() { if (confirm("Are you sure you want to continue?")) { document.getElementById("<%=txtInput.ClientID %>").value = ''; } return true; } </script>
Naeem Sarfraz
source share