Javascript "if and else" statements
Javascript "if and else" statements
我有一个Terms of Service
页面,我想强制用户在单击接受按钮之前检查Checkbox
。否则,它应该显示一个弹出消息,说
在继续
之前请先阅读使用条款,如果它被选中并点击接受按钮,他们将被重定向到官方网站。
有人能帮我吗?try this:
<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>©<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>
检查submit handler
中的condition
if (formname.checkboxname.checked == true)
{
//showalert
return false;
}else{
//open your page
}
相关文章:
- 铬:“;未捕获的语法错误:意外的标记:"
- 可以设置“;文件名"发生错误时显示的内联脚本标记的
- JS表单提交"无法使用Chrome数据保护程序加载此页面.尝试重新加载页面.调试信息:POST CISmtuK
- 检测电话窃听,即:<a href="电话:xxx">在UIWebview上
- 使用“+="操作人员
- //而不是在src=“”上使用http://"属性
- "未捕获的语法错误:意外的标记}"
- 可以<脚本类型=“;text/javascript”>window.location=“/"</
- "实例范围”;TypeScript类的getter/setter
- Javascript复选框函数:;缺少:在属性id之后"
- "“;变量未引用正确的对象
- "日期“;AJAX请求返回的类型值未定义
- 得到"TypeError:无法读取属性'filename'未定义的“;调用“npm start
- Soundcloud api"未捕获的类型错误:无法读取属性'uri'“未定义”;
- "工具提示"jQuery插件坏了
- "锻造;React中的表达式
- 图像可以从源<img src=""/>.TEXT可以在没有javascript的情况下从外部
- 如何提取“;href"最近列表项中的属性值
- CKEditor如何允许href="javascript:void(0)"在小部件中
- 插入“;img src"在javascript中