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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T21:59:26+00:00 2026-05-19T21:59:26+00:00

I found this tutorial which uses jQuery and validation plugin to validate form input.

  • 0

I found this tutorial which uses jQuery and validation plugin to validate form input. Please see the working example here.
http://jsfiddle.net/nK7Pw/
This seem to work fine, however I have a question that in the html part, there is no where mentioned error class, then how does the code displays the error just in front of each field? There is no such explanation in the jQuery part too. Thanks for explaining.

  • 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-19T21:59:27+00:00Added an answer on May 19, 2026 at 9:59 pm

    It’s all done internally by the validation plugin.

    errorClass: "error",
    errorElement: "label",
    

    It defines default classes and objects to place in the DOM when an error occurs.

    It has an error placement function called internally. It will loop through the error list and then call showLabel on the element & message

    defaultShowErrors: function() {
                for ( var i = 0; this.errorList[i]; i++ ) {
                    var error = this.errorList[i];
                    this.settings.highlight && this.settings.highlight.call( this, error.element, this.settings.errorClass, this.settings.validClass );
                    this.showLabel( error.element, error.message );
                }
    

    Then it comes along and runs the showLabel function.

    showLabel: function(element, message) {
                var label = this.errorsFor( element );
                if ( label.length ) {
                    // refresh error/success class
                    label.removeClass().addClass( this.settings.errorClass );
                    // check if we have a generated label, replace the message then
                    label.attr("generated") && label.html(message);
    

    If the label already exists Then it will refresh the error class and set the new message in the label.

    If it didnt exist then we make one. It has a large constructor block, setting the attribute and the class as well as the message.

                } else {
                    // create label
                    label = $("<" + this.settings.errorElement + "/>")
                        .attr({"for":  this.idOrName(element), generated: true})
                        .addClass(this.settings.errorClass)
                        .html(message || "");
    

    It does a bit of extra hackery to for IE to show the label

                    if ( this.settings.wrapper ) {
                        // make sure the element is visible, even in IE
                        // actually showing the wrapped element is handled elsewhere
                        label = label.hide().show().wrap("<" + this.settings.wrapper + "/>").parent();
                    }
    

    And right here we have the DOM insertion code.

                    if ( !this.labelContainer.append(label).length )
                        this.settings.errorPlacement
                            ? this.settings.errorPlacement(label, $(element) )
                            : label.insertAfter(element);
                }
    

    This has all been pasted from the jQuery.validation source. If something else is unclear feel free to ask. Just searching through the file alone and reading the source should help. I just searched for “error”

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

Sidebar

Related Questions

Reading this question I found this as (note the quotation marks) code to solve
I found this open-source library that I want to use in my Java application.
I found this link http://artis.imag.fr/~Xavier.Decoret/resources/glsl-mode/ , but there isn't a lot of description around
I found this in an article on Multithreaded Apartments, but can’t find a definition
Just found this out, so i am answering my own question :) Use a
I found this guide for using the flash parameters, thought it might be useful
I found this PECL package called threads , but there is not a release
I found this: http://www.evolt.org/failover-database-connection-with-php-mysql and similar examples. But is there a better way? I
I found this via google: http://www.mvps.org/access/api/api0008.htm '******************** Code Start ************************** ' This code was
I found this page describing the Muenchian method, but I think I'm applying it

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.