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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:17:55+00:00 2026-06-14T22:17:55+00:00

Ok, I think I have this wrong…but I cant seem to get the answer.

  • 0

Ok, I think I have this wrong…but I cant seem to get the answer. Im just trying to create a success checkmark or indicator that what the user has entered into the input form is valid. The commented out portion of the script is the idea of what Im trying to achieve. Here is the script:

$('document').ready(function(){
    $('form').validate({
        rules: {
           a: {required:true, minlength:2},
           b: {required:true}
        },      
        messages: {
           a: {required: "enter your name!"},
           b: {required: "enter the date!"}                        
        },
        errorPlacement: function(error, element) {
        if(element.attr('name') == 'a'){
             $('#name').html(error);                
         }
         if(element.attr('name') == 'b'){
             $('#date').html(error);                
         }
        },
        success: function(error){
            //a: {$('#name').html('nice name!');},
            //b: {$('#date').html('nice date!');}                           
        },
        debug:true
    });
    $('#a').blur(function(){
        $("form").validate().element("#a");
    });
});

And here is the html:

<form action="#" id='commentForm'>
    <input type="text" name="a" id="a">
    <input type="text" name="b" id="b">
    <button type="submit">Validate!</button>
<div id="date" style="border:1px solid blue;"></div>
<div id="name" style="border:1px solid red;"></div>
</form>

Last, but not least, here is the jsfiddle:

http://jsfiddle.net/mmw562/wQxQ8/8/

Many thanks in advance for your help!

  • 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-14T22:17:57+00:00Added an answer on June 14, 2026 at 10:17 pm

    The part inside success: would be a class name or a JavaScript callback function, which looks just like any other function. But instead, you wrote it like an array of plugin options. Also, since it’s called “success”, why would error be passed into it when there wouldn’t be any? As per the documentation it should look something like this…

    success: function(label){
        label.addClass("valid").text("Ok!");                        
    },
    

    http://docs.jquery.com/Plugins/Validation/validate#toptions

    If specified, the error label is displayed to show a valid element. If
    a String is given, its added as a class to the label. If a Function is
    given, its called with the label (as a jQuery object) as its only
    argument. That can be used to add a text like “ok!”.

    Here is your jsFiddle slightly modified to show the basic concept. Perhaps you can use a checkmark as a background-image in the CSS of the .valid class.

    http://jsfiddle.net/wQxQ8/12/

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

Sidebar

Related Questions

I have this problem. i think it is simple but i just couldn't get
I think I have this working but I need advice. I'd like to know
I have this vb.net code ( but I think meaning code is equivalent for
I have this plugin issue for ages but can't get it right. Here is
I think I have done this before, but it could also be a function
Hi I think I may have done this the wrong way round can anyone
Please see the back trace below, I don´t think I have seen this before
So I have this idea for a RubyGem that I think would be an
I have this program that I am working on for class, I think the
I have this.... function MyFunction() { var myVar = I think I am encapsulated;

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.