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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:06:55+00:00 2026-06-08T07:06:55+00:00

My scenario is this: I’m runing Contact Form 7 (contactform7.com). When a user have’nt

  • 0

My scenario is this:

I’m runing Contact Form 7 (contactform7.com). When a user have’nt set the required fields and pressed send (the form is sent with jQuery, so a page reload is’nt initiated) the Contact Form 7 script outputs a “error class” to the input field where the user have missed to fill out.

This class – which the Contact Form 7 have set – I want to grab. But it seems that hasClass() does’nt work on this. It just works on predefined classes.

My conclusion is that the class which hasClass() tries to grab is’nt available at some how when the whole page is’nt reloaded.

How do I solve this and can be able to grab the class?

Edit: I have this code

$('input:text, textarea').click(function() {
        $(this).css({'background' : '#fff'});
    });

If you have missed to fill out a required input/textarea and pressed “Send”, the field comes up with a red background (this is right). The above code makes them white on click (this is right). But if you forget to fill a required input/textarea the second time and pressed “Send”, the field you have forgot to write something in comes up as white (background) and not red (this is wrong).

My thoughts is that the above code overrides the other CSS classes. How do I avoid 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-08T07:06:57+00:00Added an answer on June 8, 2026 at 7:06 am

    As you said you are using contact form 7( i hope in wordpress) you can directly edit the javascript of the contactform7. so to make hasClass() working you should write it in that file by binding it with some event like for example on Click of submit button.

    and for the error styling you should not add new inline styles because when the form is validated next time it will remove the applied error class(if no validation error are not there) and add error class (if validation error was there) but your style will retain there and override the applied class. So instead of adding new styles onclick of textarea or text box remove the applied error class for it

    for example:-

    $('input:text, textarea').click(function() {
            $(this).removeClass('your error class');
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please cosider this scenario: I have a form with 3 drop down list.I place
Consider this scenario. I have my own website, that I use as my identifier,
Consider this scenario. I have an object, lets call it.... Foo. Foo raises a
Imagine this scenario: You have a desktop and a laptop. The desktop has a
In this scenario, I have 2 or more models: class Store(models.Model): name = models.CharField(max_length
I have this scenario well, i'll let the model explain. public class ScheduleMonthlyPerDayModel {
My scenario is this: I have a base NHibernate query to run of the
Consider this scenario. I have some business logic that now and then will be
Consider this scenario: I have a project with two modules and one common module
Take this scenario. I have a Google Analytics tracking code, and I only want

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.