验证javascript中的复选框 [英] Validate checkbox In javascript

查看:44
本文介绍了验证javascript中的复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好专家,
我有一个注册页面,其中在向导控件内部存在一个条款和条件部分,其中包含一个复选框.当用户单击向导的下一步按钮时必须选中它,否则它将显示一条消息,请检查条款和条件;我尝试了以下脚本,但不适用于向导控制

Hello Experts,
I have a Register page in which a terms and condition section is present Inside Wizard control which contain a checkbox.It must be checked when user click the next button of wizard.Otherwise it will show a message please check terms & condition.I have tried the following script but it isnot working for wizard control

<SCRIPT type="text/javascript">
<!--
//Accept terms & conditions script (by InsightEye www.insighteye.com)
//Visit JavaScript Kit (http://javascriptkit.com) for this script & more.
function checkCheckBox(f){
if (f.ctl00_ContentPlaceHolder1_Wizard2_chkAgree.checked == false)
{
alert('Please check the box to continue.');
return false;
}else
return true;
}
//-->
</SCRIPT>




请提供解决方案
谢谢
Sandeep(软件开发人员)




Please provide me the solution
Thank You
Sandeep (Software Developer)

推荐答案

请使用以下内容

Please use following

function checkCheckBox(){
var chk = document.getElementById('<%=chkAgree.ClientID%>');
  if (chk.checked == false)
  {
     alert('Please check the box to continue.');
     return false;
  }
  else
    return true;
}



谢谢,
Imdadhusen

更新说明:-
我已经从函数中删除了参数,因为现在不再需要它了!



Thanks,
Imdadhusen

Updates Note:-
I have removed parameter from function because now it is no more nedded!

function checkCheckBox()


这篇关于验证javascript中的复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆