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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T13:22:46+00:00 2026-05-29T13:22:46+00:00

I run some validation on my form when a checkbox is clicked, which works

  • 0

I run some validation on my form when a checkbox is clicked, which works as intended.

$('#ilikeicecream').click(function(){
     runValidation();
});

The checkbox also has a label element, so I need to check for that as well. My first instinct was to do the following:

$('#ilikeicecream-label').click(function(){
     runValidation();
});

The problem is that the checkbox has not been checked at this point so validation does not work as intended. How can I get around 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-05-29T13:22:47+00:00Added an answer on May 29, 2026 at 1:22 pm

    Use change():

    $('#ilikeicecream').change(function(){
         runValidation();
    });
    

    For select boxes, checkboxes, and radio buttons, the event is fired
    immediately when the user makes a selection with the mouse, but for
    the other element types the event is deferred until the element loses
    focus.


    I’ve tested in jsFiddle with the following code. I’m unable to provide a link however as jsfiddle is currently down.

    <label for="ilikeicecream">sdsd</label><input id="ilikeicecream" type="checkbox" />
    
    $('#ilikeicecream').change(function(){
         alert("test");
    });
    

    If this is not working, perhaps you have not specified the for attribute in your label to match the input.

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

Sidebar

Related Questions

I have some client-side JavaScript validation on a form. It works great. But I
I have a form that I'm trying to run some basic validation on using
i'll try and be as clear as possible. I'm working on some form validation
Im trying my first form validation with PHP. I need some guidance with the
I have a form using jquery validation plugin. My submit button has an ajax
I am submitting a ColdFusion Form and I want to run some JavaScript to
I'm having some issues using rails validation on a form. What I'm doing is,
Basically, I have a form and a validation function that executes when a form
I am having a problem with some bean validation. Basically I have a form
My task is to perform validation on form which fields are constructed dynamically(upon database

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.