Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7718509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:11:03+00:00 2026-06-01T03:11:03+00:00

I found simple textbox watermark script that I was going to use in my

  • 0

I found simple textbox watermark script that I was going to use in my project but I can’t understand whats wrong, I tried debugging with Firebug and I can see it going through jquery code only once when page is loaded,after that textbox acts like nothing was binded to its focus or blur and I don’t see any breakpoints getting hitted in script, here is whole layout page with script:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <title>@ViewBag.Title</title>
    <link href="@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/Content/css")" rel="stylesheet" type="text/css" />
    <link href="@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/Content/themes/base/css")" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/Scripts/js")"></script>

    <style type="text/css">
    .water
    {
         font-family: Tahoma, Arial, sans-serif;
         color:gray;
    }
    </style>

    <script type="text/javascript">
        $(document).ready(function () {

            $(".water").each(function () {
                $tb = $(this);
                if ($tb.val() != this.title) {
                    $tb.removeClass("water");
                }
            });

            $(".water").focus(function () {
                $tb = $(this);
                if ($tb.val() == this.title) {
                    $tb.val("");
                    $tb.removeClass("water");
                }
            });

            $(".water").blur(function () {
                $tb = $(this);
                if ($.trim($tb.val()) == "") {
                    $tb.val(this.title);
                    $tb.addClass("water");
                }
            })
        });       

    </script>
</head>
<body>
  <div class="wrapper">
    <div id="messageBox" align="center">
    </div>
        <div class="header">
            <div class="header-column">
               <h1 id="logo" class="no-border"><a href="/"><img src="../../Content/themes/base/images/ps-logo.png" style="margin-top:10px;" alt="" /></a></h1>
            </div>
            <div class="header-column lh50" align="center">
                <div>
                    <input type="text" ID="txtSearch" class="water" title="Search" value="" />
                </div>
            </div>
            <div class="header-column">
                <div class="main-menu lh50">
                    <ul>
                        <li>
                           @if(!Request.IsAuthenticated)
                           {
                                    <a href="Login">Login using
                                        <img alt="Facebook" src="../../Content/themes/base/icons/facebook-icon.png" class="login-icon" />
                                        <img alt="Google" src="../../Content/themes/base/icons/google-icon.png" class="login-icon" />
                                        <img alt="Yahoo" src="../../Content/themes/base/icons/yahoo-icon.png" class="login-icon" />
                                    </a>  
                                    <span> or  </span>
                                    <a href="#">Register</a>
                           }
                           else{
                                    <span>@GetCurrentUsername(this.Context)</span>

                                    <a href="#">Log out</a>

                                    <a href="#">Post</a>

                                    }
                        </li>
                    </ul>
                </div>
            </div>
        </div>
        <div class="clear">
        </div>
          @RenderBody()
      <div class="push">
        </div>
    </div>
    <div class="footer" align="center">
        <ul>
            <li><a href="#">Home</a></li>
            <li><a href="#">Services</a></li>
            <li><a href="#">Portfolio</a></li>
            <li><a class="active" href="#">Resources</a></li>
            <li><a href="#">Contact</a></li>
        </ul>
        <p>
            Copyright © 2012 Domain - All rights reserved</p>
    </div>
</body>
</html>

Is there problem in mvc4, my code or something else?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T03:11:04+00:00Added an answer on June 1, 2026 at 3:11 am

    The script works, you just need to ensure that the value of the textbox is the same as the title initially:

    <input type="text" ID="txtSearch" class="water" title="Search" value="Search" />
    

    Because that’s what you are checking here:

    $(".water").each(function () {
        $tb = $(this);
        if ($tb.val() != this.title) {
            $tb.removeClass("water");
        }
    });
    

    And if the value is different than the title (in your case title=”Search” and value=””) you remove the water class and nothing will happen later.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've made a previous post that tried to use a textbox. From this I
I found an odd problem when I run a simple csh script on Solaris.
Simple question, but I haven't found a good explanation on google. When using Set
should be simple right? but have not found any anwsers :
I have a very simple MVC site that is returning a 404 not found
Is there a simple way, without .NET? I've found some libraries but none for
I'm trying to implement a simple watermark on a text box that disappears when
Has anyone found html textarea plugin that works with iPad? If i use any
I just published this simple console application that is supposed to show a textbox
I am using a simple live search script that displays the results from a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.