0

我正在使用 joomla 1.5,需要添加一个具有条款和条件名称的复选框。我已经使用了下面的代码,但它没有完全工作。即使我勾选了复选框,它也会发出警报。

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

1 回答 1

0
if ($("#formAgree").not(":checked")) {
  alert('To become a member you must agree to our terms of service!');
    return false;
} 
 return true;
于 2012-10-30T11:07:32.127 回答