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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:22:19+00:00 2026-05-27T09:22:19+00:00

I use jQuery to simulate the HTML5 placeholder function: // placeholder code $(function() {

  • 0

I use jQuery to simulate the HTML5 placeholder function:

// placeholder code
$(function() {
    $('[placeholder]').focus(function() {
      var input = $(this);
      if (input.val() == input.attr('placeholder')) {
        input.val('');
        input.removeClass('placeholder');
      }
    }).blur(function() {
      var input = $(this);
      if (input.val() == '' || input.val() == input.attr('placeholder')) {
        input.addClass('placeholder');
        input.val(input.attr('placeholder'));
      }
    }).blur().parents('form').submit(function() {
      $(this).find('[placeholder]').each(function() {
        var input = $(this);
        if (input.val() == input.attr('placeholder')) {
          input.val('');
        }
      })
    });
});

When I now submit the form without changing the placeholders, it uses the placeholders as values.

Can you tell me how to remove all values / placeholders from the textfields when clicking on the submit button? I have seen some solutions here, but it didn’t work with the placeholder attribute.

Here is one of my textfield:

<input class="frmInputLong" name="inptName" type="text" value="" placeholder="Peter Smith">

Here is my form definition:

<form id="frmBook" method="post" action="doSomething" >
  • 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-05-27T09:22:20+00:00Added an answer on May 27, 2026 at 9:22 am

    Either execute the submit using jQuery’s .submit or add .click handler to the submit button. Inside the function you can do something along the lines of:

    $("input").attr("placeholder", "");
    

    This sets the value of the attribute “placeholder” to an empty string.

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

Sidebar

Related Questions

I use jquery for adding table dynamically and I use this pattern: var tbl
I use jquery code: $.ui.keyCode.COMMA only can Capture Single Byte Character input,How can Capture
my iphone can't use jquery , so i have to simulate $ function by
I use jquery post function to go to server and bring the link to
I use jQuery to fade in a caption on a icon mouseover. $(#v1).mouseover(function() {
I'm trying to use jQuery to format code blocks, specifically to add a <pre>
I use JQuery Datepicker and cannot get data from it. In .html: <p>Date: <input
I use Jquery tools rangeinput . For example I have: <input id=testId title=test class=range
EDIT 2/13: The Panels widget in jQuery Mobile 1.3 now exists! Please use this
i use jquery serialize but it returns empty string. <form id=form1 runat=server> <input name=kongreAd

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.