SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict mari's Avatar
    Join Date
    Nov 2007
    Location
    London, UK
    Posts
    218
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation Javascript not working in IE??

    Hi Guys,

    im having some issues with javascript and IE8, i have a form which has a small javascript checkbox so that users must check that they have read terms and conditions before they can submit the form, if the box is not checked a little msg pops up asking them to check this box

    it works fine in firefox but nothing happens when i try in IE, it seems to have disabled the submit button all together

    here is my code
    Javascript:

    Code:
    <script type="text/javascript">
    window.onload=function(){
    document.forms[0].onsubmit=function(){
       return checkIt();
      }
     }
    
    function checkIt() {
    if(document.getElementById('tos').checked==false) {
       alert('you need to check the "I accept terms of service" box');
       document.getElementById('tos').className='highlight'
       return false;
      }
    else {
       document.getElementById('tos').className='';
       return true;
      }
     }
    </script>
    html:
    Code:
    <form method="post" action="#">
    <input id="tos" type="checkbox"><label for="tos"> I accept terms of service</label>
    </form>
    does anyone know where i am going wrong?

    thanks

  2. #2
    SitePoint Guru
    Join Date
    Sep 2006
    Posts
    731
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There's nothing wrong with what you've shown, so we need a URL or runnable demo.
    Tab-indentation is a crime against humanity.

  3. #3
    SitePoint Guru
    Join Date
    Apr 2006
    Posts
    802
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <form method="post" action="#">
    <input id="tos" type="checkbox"><label for="tos"> I accept terms of service</label>
    </form>
    How do you get a submit event from this form?


Bookmarks

Posting Permissions

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