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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:27:25+00:00 2026-06-10T08:27:25+00:00

I am using jquery and validate to validate my form. Instead of adding an

  • 0

I am using jquery and validate to validate my form.
Instead of adding an element to the missing field I am adding a border to the element
using this option errorPlacement

$("#signup-form").validate({
       submitHandler: function(form) {
      form.submit();
   },
   errorPlacement: function(error, element) {
      element.css("border", "solid 1px red");
   }                    
});

the one thing i can not seem to figure out is how to clear it when valid?

So I started with the above code. Then tried and i am confused with the results.
If I do not have the success: option when a field fails it adds the class successfully. But as soon as I add the success option all the required fields are getting that class, and if I inspect the element I see <input class="required invalid valid"> so I am doing something incorrectly.

           $("#signup-form").validate({
                submitHandler: function(form) {
                    // do other stuff for a valid form
                    //form.submit();
                },
                errorPlacement: function(error, element) {
                    element.addClass("invalid");
                },        
                success: function(error) {
                    // change CSS on your element(s) back to normal
                },                    
                 debug:true
            });
  • 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-10T08:27:27+00:00Added an answer on June 10, 2026 at 8:27 am

    You could try adding this to your list of .validate() options…

    success: function(error) {
        // change CSS on your element(s) back to normal
    }
    

    This should work dynamically without a form submit. As soon as the error is resolved, the contained code will run.

    See documentation.

    Please create a demo of your problem using jsFiddle. Here’s a blank jsFiddle with .validate() already included and ready for use.


    EDIT

    As per OP’s jsFiddle, I made these changes…

        errorPlacement: function(error, element) {
            $(element).filter(':not(.valid)').addClass("invalid");
        },
        success: function(error) {
            console.log(error);
            $("#signup-form").find('.valid').removeClass("invalid");
        }
    

    Working Demo: http://jsfiddle.net/u3Td3/6/

    Side-notes: You also had some HTML issues. You should “self-close” your input elements with />. Same thing for the submit button, self-close rather than using a </input>. See validator.w3.org to validate your HTML. I’d also not use a table for layouts, use CSS.

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

Sidebar

Related Questions

I'm using the jQuery validate plugin to validate a multi-step form like this one:
I want validate my form using jquery (the field 'name1' is required and 'email'
I'm try to validate form using jquery validation plugin my from code: source code
I need to be able to validate fractions on my form using jquery.validate and
I am trying to using a jquery.validate.unotrusive.js plugin to dynamically created form fields like:
i try to validate the form before submitting the request. i am using jquery
I'm using the Jquery Validation plugin to validate my form on the client before
I'm using JQuery Validation to validate a particular textbox in my form. The textbox
I've cobbled together a jQuery function to validate email and submit the form using
I'd like to validate a form using the jquery validate plugin, but I'm unable

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.