0

"What I am trying to achieve is onclick will remove the text within a textbox".

I read some answers from this site which someone is using "function pageLoad(sender, args)" javascript but the problem is that on debug using Firefox break point the function line doesn't stop on it. Am I missing a loaded up javascript requirement from microsoft or something else? here is my test code.

    function pageLoad() {
        $("#<%=Text_Message.ClientID%>").click(function () {
            alert("Handler for .click() called.");
        });
    }
    $(document).ready(function () {
        $("#<%=Text_Message.ClientID%>").click(function () {
            alert("Handler for .click() called.");
        });
    });

textbox

<asp:TextBox ID="Text_Name" runat="server" CssClass="" Width="234px" >Name</asp:TextBox>
Community
  • 1
  • 1
Akyl
  • 349
  • 1
  • 4
  • 21

1 Answers1

2

use focus instead of click on textbox and empty its text using $(this).val("");

Live Demo

$(document).ready(function () {
        $("#<%=Text_Message.ClientID%>").focus(function () {
            alert("Handler for .click() called.");
            $(this).val("");
        });
 });
Adil
  • 146,340
  • 25
  • 209
  • 204