Q:

Joomla Registration form with Terms & Condition Checkbox

i am using joomla 1.5, need to add a checkbox having terms and conditions name. I have used the below code but its not worked fully. its alerting even i have tick the checkbox. 
<script type="text/javascript"><!--

 function checkAgree() {
     var agree = document.getElementById('formAgree');         
     if (!agree.checked) {
        alert('To become a member you must agree to our terms of service!');
        return false;
     } 
     return true;
 }

--></script>
<form action="<?php echo JRoute::_( 'index.php?option=com_user' ); ?>" method="post" id="josForm" name="josForm" class="form-validate" onsubmit="return checkAgree();">

<?php

 // Terms of Service

 $tokenHTML = str_replace('type="hidden"','id="formAgree" type="checkbox"',JHTML::_( 'form.token' ));

 $tosURL = "tos.html"; // REPLACE THIS!

?>
<tr>
   <td height="40" style="vertical-align: top;">
      <label>
         Terms of service:         
      </label>
   </td>
   <td>
      <iframe src="<?php echo htmlentities($tosURL); ?>" width="307" height="150"></iframe>
   </td>
</tr>
<tr>
  <td colspan="2">
    <p><?php echo $tokenHTML; ?> <b>Agree to terms of service.</b> *</p>
  </td>
</tr>
<tr>

A:

if ($("#formAgree").not(":checked")) {
  alert('To become a member you must agree to our terms of service!');
    return false;
} 
 return true;

