How to Display Text in TextBox in Web Application

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • singh79
    New Member
    • Jul 2007
    • 16

    How to Display Text in TextBox in Web Application

    Hi

    Pls Any One Solve My Problem.

    One Text box for Enter user Name.My Requirement is if web application is Run then, In Textbox Display "Pls Enter User name" If Click By Mouse the text Is Gone.If Enter Usename, If In Case Do Not Enter User Name, Again Come And Display "Pls Enter User Name"


    Thanks & Regards
    Atul Singh
  • navneetkaur
    New Member
    • Sep 2007
    • 45

    #2
    Originally posted by singh79
    Hi

    Pls Any One Solve My Problem.

    One Text box for Enter user Name.My Requirement is if web application is Run then, In Textbox Display "Pls Enter User name" If Click By Mouse the text Is Gone.If Enter Usename, If In Case Do Not Enter User Name, Again Come And Display "Pls Enter User Name"


    Thanks & Regards
    Atul Singh
    hi Atul u do this work on pageload.....by default enter "Pls Enter User name" 'd by jusing javascript on mouseclick event of textbox jst clear it 'd write whatever u want to write....'d then i suppose there is submit event on this check that textbox contents if it is equalt to ur "Pls Enter User name" this then send message enter correct username 'd tell me this help u or not


    enjoy coding.....
    Navneet

    Comment

    • singh79
      New Member
      • Jul 2007
      • 16

      #3
      Ok,

      I Agree With u...

      But How ,Pls Give Me Code And How To Call Java Script In Page Load..

      Full Code.Any One Display.....

      Pls Help Me..
      Regards
      Atul Singh

      Comment

      • krris
        New Member
        • May 2007
        • 10

        #4
        Textbox :
        <asp:TextBox ID="txtFirstNam e" runat="server" CssClass="h_fla ttxt" Width="99px" onblur="Display Msg(this)" onfocus="Displa yMsg(this);">Fi rstName</asp:TextBox>



        Code for javascript
        in function DisplayMsg(TxtN ame)
        if(TxtName.valu e.length > 0)
        {
        if(TxtName.valu e != 'FirstName' && TxtName.value.l ength > 0)
        {
        TxtName.value = TxtName.value;
        TxtName.classNa me = 'flattxt';
        }
        else
        {
        TxtName.value = '';
        TxtName.classNa me = 'flattxt';
        }
        }
        else
        {
        TxtName.value = 'FirstName';
        TxtName.classNa me = 'h_flattxt';
        }

        Comment

        • singh79
          New Member
          • Jul 2007
          • 16

          #5
          Pls I Am Sorry That..

          This Code is Not Run ...
          Pls Give Me Details How To Run ..

          I am Written Same Code sending By U But Not Run ..


          Pls Give Me Proper Solution....


          Regards
          atul

          Comment

          Working...