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

The Archive Base Latest Questions

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

I have come across a rather strange behaviour. I have two pages (lets call

  • 0

I have come across a rather strange behaviour. I have two pages (lets call them page A and page B), both pages contain the following javascript code:

<script type="text/javascript">
$(document).ready(function(){
    $('a > img.id-provider, #signup-button').click(function(e){
        if (!$('#chk-agree').attr('checked')) {
            alert('Please accept our terms and conditions before continuing');
        }
        else {
            alert('ok');
        }
        e.preventDefault();
    });
});
</script>

The page is viewable here: http://jsfiddle.net/SrRAS/

On page B, the behaviour is as expected, i.e. a warning is issued when the checkbox is not checked before the signup button is clicked.

However, on page A, the warning is always shown, if even the checkbox has been manually clicked to make it checked.

Here is the FF console output (for both pages), when I was trying to understand what was going on:

>>> $('#chk-agree').attr('checked')
undefined
>>> $('input#chk-agree').attr('checked')
undefined

Eventually, on page A, I decided to programatically set the checked attribute (instead of manually clicking it – as a normal user would):

>>> $("input#chk-agree").click()
jQuery(input#chk-agree, input#chk-agree)
>>> $("input#chk-agree").attr('checked')
"checked"

When I then clicked the signup button on page A, it worked as expected (displayed an ‘ok’ message). However, when I manually unchecked the checkbox on page A, it still continued to display an ‘ok’ message. So it seems that for some reason, on page A, manually clicking on the checkbox does not toggle the ‘checked’ attribute.

I have two questions:

  1. Why is manually checking the checkbox not toggling the checkbox ‘checked’ attribute
  2. What would cause the code to work as expected on one page and not another?

[[Edit]]

I have also tried the following check instead of the one shown in my snippet above:

if (!$(this).is(':checked')/*!$('#chk-agree').attr('checked')*/) {
   ...
}else {
   ...
}

Now, at least the behaviour is consistent across both pages in that, none of the pages (A or B) seem to acknowledge when the checkbox is manually clicked – what on earth is going on?!

[[Edit2]]

The markup of the page that is not working is here: http://jsfiddle.net/SrRAS/

I will be very interested in finding out what is causing it not to work on this page.

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

    Check out this version of your JsFiddle with Fixed code It contains two changes. checkboxes with unique IDs and correct jquery code for checked elements

    if ($('input#chk-agree').is(':checked')) {
            alert('ok');
        }
        else {
            alert('Please accept our terms and conditions before continuing');
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've come across a strange render bug on iPhone OS 3.0... I have two
I have come across the following basic Tree conflict: Local add, incoming add upon
I have come across a strange problem which I would like to get your
I have come across a rather odd situation. I have generated a a random
This is rather a funny problem I have ever come across, I have a
I have come across a strange problem with Zend_Framework, I can not load forms
I'm rather new to JAXB and have come across a problem which I can't
I have come across an annoying problem. I have made a system and now
I have come across scripts that use: isset($_POST['submit']) as well as code that uses:
I have come across many articles which warn against using links to provide logout

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.