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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:50:41+00:00 2026-06-09T18:50:41+00:00

I created a simple jquery plugin that puts ‘greyed out’ text into a textbox

  • 0

I created a simple jquery plugin that puts ‘greyed out’ text into a textbox if the field is blank (watermark for textboxes). The problem is when i submit the form and i’m trying to get the value of the text box, it’s returning the watermark text instead of an empty field.

The watermark text is equal to the “title” attribute, so i could do something like this, but i’d hate to do this for EVERY textbox in my form:

if ($("#textboxid").val() == $("#textboxid").attr("title")) {
  //default, return empty string
} else {
  //user entered this
}

Ideally, this would be part of my plugin and it would return an empty string when i call .val()
Any suggestions on how 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-09T18:50:43+00:00Added an answer on June 9, 2026 at 6:50 pm

    I have something like this for my custom made watermark/placeholder plugin i’ve made. I just handle it onclick (the submit button for your form) and then loop through everything.

    Updated jsFiddle DEMO

    (function ($, window, document, undefined) {
    
        $.fn.myCustomVal = function () {
            return $(this).each(function () {
                var _self      = $(this),
                    _watermark = _self.attr('title');
    
                _self.attr('data-watermark', 'on');
                _self.val(_self.attr('title'));
    
                _self.on('focus', function () {
                    $(this).val('');
                });
                _self.on('blur', function () {
                    $(this).val(_watermark);
                });
            });            
        };
    
        $(function () {
            // change this class here to whatever you want
            $('.btnSubmit').on('click', function () {
                $('input:text[data-watermark]').each(function () {
                    if ($(this).val() == $(this).attr("title")) {
                        $(this).val('');
                    }
                });
    
                // now validate / submit / whatnot
                alert('submitted!');
            });
        });
    
    }(jQuery, window, document));
    
    // ************************
    // Initiate plugin
    $('input:text').myCustomVal();
    

    ​

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

Sidebar

Related Questions

I have created a custom jQuery plugin that does some simple image resizing for
I just created my first jQuery plugin , it is very simple it slideToggle
I have created a quick and simple plugin that vertical aligns images that I
I've created a simple form and I'm using the Datatables jQuery plugin to display
I have created a simple JQuery script with hovering effect on some links. The
So I created a simple slideshow with jquery and jquery ui. It works perfectly
I've created a simple placeHolder for some extra javascript in jQuery - The issue
I am trying to create a simple about page that uses JQuery click to
I'm using a jquery plugin on my page, vTicker , for easy and simple
I need some jQuery plugin, tutorial or guidelines to create simple image gallery which

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.