-4

我有一个Terms of Service页面,我想强制用户Checkbox在单击接受按钮之前检查。否则它应该显示一个弹出消息说

请在继续之前阅读服务条款

如果选中并单击接受按钮,他们将重定向到官方网站。

谁能帮我?

4

2 回答 2

2

尝试这个:

<SCRIPT>

//Accept terms & conditions script (by InsightEye www.insighteye.com)
//Visit JavaScript Kit (http://javascriptkit.com) for this script & more.

function checkCheckBox(f) {
  if (f.agree.checked == false ) {
    alert('Please check the box to continue.');
    return false;
  } else {
    return true;
  }
}
</SCRIPT>

<form action="/yourscript.cgi-or-your-page.html" method="GET"
 onsubmit="return checkCheckBox(this)">

  <!--Enter your form contents here-->
  <b>By submitting, I agree that all info entered was done
     accurately & truthfully.</b><br>
     I accept: <input type="checkbox" value="0" name="agree">
  <input type="submit" value="Submit form">
  <input type="button" value="Exit" onclick="document.location.href='/index.html';">
</form>

或这个:

<form name="frm">
  <input type="checkbox" name="chk" onClick="apply()">If you click this the specified
   url will open.
  <div align=center>&copy<a href="http://www.mine.com" style="color:#3D366F;text-decoration:none;cursor:pointer;font-size=13px">hscripts.com</a></div>
</form>
<script type="text/javascript">
  function apply() {
   if(document.frm.chk.checked==true) {
     window.open("http://www.mine.com/license/license.html");
   }
  }
</script>
于 2013-03-09T20:23:43.570 回答
0

检查这个conditionsubmit handler

if (formname.checkboxname.checked == true)
   {
      //showalert

      return false;
   }else{

     //open your page
  }
于 2013-03-09T20:31:31.637 回答