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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:45:19+00:00 2026-05-30T09:45:19+00:00

There is a question form validated by Validation Plugin . It has a lot

  • 0

There is a question form validated by Validation Plugin. It has a lot of fields with checkboxes and radiobuttons, and I want them to be checked after clicking a link with href=”#checkbox-id”.

...
<label class="answer-label" for="answer-2">
  <input id="option-2.1" class="answer" type="radio" name="answer-2" value="Yes"/>
  <a href="#option-2.1">Yes</a>
</label>
...

Javascript:

$("label.answer-label a").bind("click", function(event) {
  event.preventDefault();
  var target = $(this).attr("href").replace(".", "\\.");
  $(target).click();
} );

Here is validation plugin setup:

$("form#feedback")
    .validate({ submitHandler : function ( form ) {
                form.submit();
              },
              errorClass: "invalid",
              focusInvalid : false,
              debug : true,
              invalidHandler : function ( form, validator ) {
                  var destination = validator.errorList[0].element;

                  $("html, body").animate({ scrollTop : $(destination).offset().top - 100 });
                  $(destination).focus();
              },
              highlight : function ( element, errorClass, validClass ) {
                  if ( $(element).parents(".name-company") ) {
                      $(element)
                          .removeClass(validClass)
                          .addClass(errorClass);
                  }
                  // if ( $(element).parents(".question") ) {
                  $(element)
                      .parents(".question")
                      .removeClass(validClass)
                      .addClass(errorClass);
                  // }
              },
              unhighlight : function ( element, errorClass, validClass ) {
                  if ( $(element).parents(".name-company") ) {
                      $(element)
                          .removeClass(errorClass)
                          .addClass(validClass);
                  }
                  // if ( $(element).parents(".question") ) {
                  $(element)
                      .parents(".question")
                      .removeClass(errorClass)
                      .addClass(validClass);
                  // }  
              },
              errorPlacement : function () {
                  return false;
              }
            });

The problem is: clicking on label checks the input element, but validation events fire only after the second click.

  • 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-30T09:45:21+00:00Added an answer on May 30, 2026 at 9:45 am

    I found a workaround (or, probably, a correct way to trigger validation events)! The trick is to bind the “change” event on checkboxes and radio button, like this:

        $("#feedback input[type=radio], #feedback input[type=checkbox]" )
          .bind("change", function ( event ) {
                  $("#feedback").validate().element($(this));
              } );
    

    This binding must be set before any other “change” event binding, so that every “change” event will trigger the validation check.

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

Sidebar

Related Questions

someone has used this jquery plugin for form validation? http://docs.jquery.com/Plugins/Validation i cant figure out
Does anyone know why there are question marks (with a number) after the images
There's another question: howto make diff look like svn diff? but I want the
I am using the jQuery validation plugin on my form. I set the basic
Okay, i posted a question before to fix my live validation contact form. Now
I found this tutorial which uses jQuery and validation plugin to validate form input.
probably there are a lot of people who will smile reading this question... Here's
Sorry if this is a basic question: I am having trouble doing form validation
Newbie question: There are three types of Asp.Net controls : HTML server controls, Web
There are similar question, but not regarding C# libraries I can use in my

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.