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:

<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:


<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

There’s nothing wrong with what you’ve shown, so we need a URL or runnable demo.

<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?