Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 3 of 3
  1. #1
    Senior Member tekp's Avatar
    Join Date
    Jan 2004
    Location
    A small village near a small city near a small cit
    Posts
    918
    Member #
    4667
    Liked
    1 times
    Code:
    formCheck2 = function() {
     if(document.getElementById('agree_information').checked == true
        && document.getElementById('agree_dataprotection').checked == true
        && document.getElementById('agree_declaration').checked == true) {
      document.getElementById('submitbutton').disabled = false;
     } else {
      document.getElementById('submitbutton').disabled = true; 
     }
    }
    What's wrong with this code? The function is called on a form so that the user cannot submit information before checking checkboxes to do with their information being correct, data protection and a declaration.

    It works in Firefox perfectly but the user is having problems using it in IE, i.e. the button is permanently disabled (it's default state defined by the html).

    Help?
    tekp :cheeky: tekponline.com

  2.  

  3. #2
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    Ok, after a little work, here's what I came up with... I first changed the script around, but that didn't fix the problem.

    I had originally used the onchange event to trigger the function call, but that did what you were saying - it worked in Firefox, but in IE, it didn't enable the button after checking the 3 boxes... but it DID work when I clicked somewhere else on the page.

    What this tells me is that IE treats the onchange event differently than Firefox for a checkbox. It doesn't register the event until the box loses focus (when the user clicks somewhere else).

    So I changed the onchange to onclick and it now works fine for both browsers.

    Here's the final code I came up with (you can probably just use the "onclick" part):

    HTML Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
            <title>Untitled Document</title>
            <script language="javascript" type="text/javascript">
            function formCheck2() {
                if(document.getElementById('agree_information').checked == true
                        && document.getElementById('agree_dataprotection').checked == true
                        && document.getElementById('agree_declaration').checked == true) {
                    document.getElementById('submitbutton').disabled = false;
                } else {
                    document.getElementById('submitbutton').disabled = true; 
                }
            }
            </script>
        </head>
        <body>
        <form name="test" action"#">
            <div>
                <input type="checkbox" id="agree_information" onclick="formCheck2()" />Agree Info?
            </div>
            <div>
                <input type="checkbox" id="agree_dataprotection" onclick="formCheck2()" />Agree Data Protection?
            </div>
            <div>
                <input type="checkbox" id="agree_declaration" onclick="formCheck2()" />Agree Declaration?
            </div>
            <div id="inputDiv">
                <input type="submit" id="submitbutton" disabled="disabled" />
            </div>
        </form>
        </body>
    </html>

  4. #3
    Senior Member tekp's Avatar
    Join Date
    Jan 2004
    Location
    A small village near a small city near a small cit
    Posts
    918
    Member #
    4667
    Liked
    1 times
    Brilliant thanks so much!
    tekp :cheeky: tekponline.com


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Search tags for this page

button disable not working in ie 10
,
button disabled in ie11
,

button disabled not working in firefox

,
diabled button not working in ie
,
dijit checkbox disabled property is not working in ie11
,

disabled false not working in ie

,
disabled in html not working in firefox
,
ie11 jquery setattribute disable false not working
,
input disabled not work in ie11
,
javascript to disable button doesnt work in ie10
Click on a term to search for related topics.
All times are GMT -6. The time now is 05:54 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com