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

  • Home
  • SEARCH
  • 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 9075967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T18:59:51+00:00 2026-06-16T18:59:51+00:00

On my forms when the page loads I make the default text in the

  • 0

On my forms when the page loads I make the default text in the inputs light gray like this:

var formInputs = $('#notifyForm input');
formInputs.addClass('defaultText');

Then I have them turn back to black on focus using removeClass. This all works fine. The problem I’ve run into is, if there’s an error and the page reloads to display a PHP error msg, the user’s text that’s still in the inputs, turns gray. My solution for this is:

formInputs.addClass(function()
{
    if($(this).attr('value') === $(this).attr('title'))
    {
        $(this).addClass('defaultText');
    }
});

But I know there has to be something wrong with calling addClass inside an addClass handler. Can anyone suggest a better way to do this? Thank you.

  • 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-16T18:59:52+00:00Added an answer on June 16, 2026 at 6:59 pm

    From the function you pass to addClass you can return a string which will be the class name you want to add. Try this:

    formInputs.addClass(function() {
        if (this.value === this.title)
            return 'defaultText';
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page that loads a complicated set of forms. In this set
I have a form which has three inputs when the page loads -- 2
I have two forms on one page and want to have the input boxes
I have this page which loads quotes. It has a search form wherein if
I'm trying to make a xmlHttpRequest before the page body loads. When trying to
I have designed a tabbed page. I'm able to load forms in the tabs
I have web forms page that has 2 controls. A gridview and an associated
i want a handler to redirect to a web-forms page, pre-filling in the values
I have multiple ajax forms on page that cointain same elemets, I have jquery
I have 4 forms on a page. Form 1 must be submitted with either

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.