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 9022787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:36:17+00:00 2026-06-16T05:36:17+00:00

I use this jquery function to display a textbox hint this is function function

  • 0

I use this jquery function to display a textbox hint

this is function

function textboxHint(id, options) {
    var o = { selector: 'input:text[title]', blurClass:'blur' };
    $e = $('#'+id);
    $.extend(true, o, options || {});

    if ($e.is(':text')) {
      if (!$e.attr('title')) $e = null;
    } else {
      $e = $e.find(o.selector);
    }
    if ($e) {
      $e.each(function() {
      var $t = $(this);
      if ($.trim($t.val()).length == 0) { $t.val($t.attr('title')); }
      if ($t.val() == $t.attr('title')) {
    $t.addClass(o.blurClass);
      } else {
        $t.removeClass(o.blurClass);
      }

     $t.focus(function() {
    if ($.trim($t.val()) == $t.attr('title')) {
      $t.val('');
      $t.removeClass(o.blurClass);
    }
    }).blur(function() {
      var val = $.trim($t.val());
      if (val.length == 0 || val == $t.attr('title')) {
        $t.val($t.attr('title'));
        $t.addClass(o.blurClass);
      }
    });

         // empty the text box on form submit               
    $(this.form).submit(function(){
      if ($.trim($t.val()) == $t.attr('title')) $t.val('');
    });
   });
 }
}

this is html

<form action="" method="" class="search" >
    <input type="text"  name="search" class="text"  title="Search Subjects..." id="block" />
    <input type="submit"  name="submit"  value="Search" class="submit" />
</form>

I called function like this..

$(document).ready(function() {
    textboxHint("block");
});

This is working.. but the problem is now I need to use this function to display a hint in two different text box with two different Ids. Eg: Id = block1 and Id = block2 etc…

Can anybody help me in modifying this function to do this?

  • 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-16T05:36:18+00:00Added an answer on June 16, 2026 at 5:36 am

    What about this:

    $(document).ready(function() {
        textboxHint("block1");
        textboxHint("block2");
        textboxHint("block3");
    });
    

    As you can see, since the function ask for id as an argument, you can supply different id by calling the function more than once.

    Regards

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

Sidebar

Related Questions

I have this jQuery file jQuery(document).ready(function() { var orderId= <%= OrderLi.ClientID %>; jQuery(#ApprovalTab).css(display, block);
I use this jquery function to show a hint in form's inputs. Now I
I generally use this in jquery $(document).ready(function() { //stuff } I was just on
I need to call some jQuery .load() function from flash. i Use this: import
I used to use this script for jquery email obfuscation: $(.replaceAt).replaceWith(@); $(.obfuscate).each(function () {
I use this script: $(document).ready(function() { $page = jQuery.url.attr(file); alert(page); }); but I get
Typical jQuery over-use: $('button').click(function() { alert('Button clicked: ' + $(this).attr('id')); }); Which can be
I use the following jquery statements but i get error in this function onGetDataSuccess(result)
I want to use jquery delegate to call a function, and this works fine:
I use the following jquery statements, $(.resultsdiv:odd).css(background-color, #fff); $(.resultsdiv:even).css(background-color, #EFF1F1); $('.resultsdiv').hover(function() { $(this).css('background-color', '#f4f2f2');

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.