zoukankan
html css js c++ java
Javascript判断多选框checkbox和单选钮是否选中
//
第几个没有选
<
input type
=
"
checkbox
"
name
=
"
checkbox1
"
checked
>
<
input type
=
"
checkbox
"
name
=
"
checkbox1
"
>
<
input type
=
"
checkbox
"
name
=
"
checkbox1
"
checked
>
<
input type
=
"
checkbox
"
name
=
"
checkbox1
"
>
<
input type
=
"
checkbox
"
name
=
"
checkbox1
"
>
<
script language
=
javascript
>
function
check(obj)
{
for
(i
=
0
;i
<
document.all(obj).length;i
++
)
{
if
(
!
document.all(obj)[i].checked)alert(
"
第
"
+
(i
+
1
)
+
"
个没有选择
"
)
}
}
</
script
>
<
input type
=
button onclick
=
"
check('checkbox1')
"
value
=
"
检测
"
>
//
一个也没有选
<
input type
=
"
checkbox
"
name
=
"
test
"
>
<
input type
=
"
checkbox
"
name
=
"
test
"
>
<
input type
=
"
checkbox
"
name
=
"
test
"
>
<
input type
=
"
checkbox
"
name
=
"
test
"
>
<
input type
=
"
checkbox
"
name
=
"
test
"
>
<
Script Language
=
"
JavaScript
"
>
function
check(obj)
{
for
(i
=
0
;i
<
document.all(obj).length;i
++
)
{
if
(document.all(obj)(i).checked)
{
return
;
}
}
window.alert('一个也没有选!');
}
</
Script
>
<
input type
=
button onclick
=
"
check('test');
"
value
=
"
检测
"
>
<
script language
=
"
javascript
"
>
function
checkme()
{
var
checkmemberid;
//
定义团员
var
checkcontentid;
//
定义文章
checkmemberid
=
false
;
checkcontentid
=
false
;
//
判断团员是否选中
if
(document.all.memberid.checked
==
true
)
//
只有一个单选钮的情况
{
checkmemberid
=
true
;
}
for
(i
=
0
;i
<
document.all.memberid.length;i
++
)
//
有一组单选钮的情况
{
if
(document.all.memberid(i).checked)
{
checkmemberid
=
true
;
}
}
//
判断文章是否选中
if
(document.all.contentid.checked
==
true
)
//
只有一个单选钮的情况
{
checkcontentid
=
true
;
}
for
(i
=
0
;i
<
document.all.contentid.length;i
++
)
//
有一组单选钮的情况
{
if
(document.all.contentid(i).checked)
{
checkcontentid
=
true
;
}
}
//
将结果返回
if
(checkmemberid
==
false
)
{ window.alert(
"
请选择团员!
"
);
return
false
;
}
else
if
(checkcontentid
==
false
)
{
window.alert(
"
请选择文章!
"
);
return
false
;
}
return
true
;
}
</
script
>
查看全文
相关阅读:
win10安装vue
通过docker安装rabbitmq
python定时访问主机进程信息并反馈到远程服务器
win10配置Apache+部署静态html页面
HTTP协议—HTTP报文格式详解
python脚本编写(纯干货)
linux/CentOS的安装(萌新版)
gradle中调用ant.unzip对zip包解压缩
通过gradle运行测试脚本
使用rest-assured测试rest service, 遇到“415 Unsupported Media Type”
原文地址:https://www.cnblogs.com/ghd258/p/270758.html
最新文章
三元运算符
逻辑运算符
if-else
选择题数组
9*9乘法表
arraylist 排序
公鸡母鸡小鸡问题
字符转ascii与ascii 转字符
idea-maven-junit安装使用
oracle-cmd -sqlplus 连接数据库
热门文章
Oracle出现ora-01045的解决方法-可用
ORA-01219:数据库未打开:仅允许在固定表/视图中查询-可用
ora 00904标识符无效
Update Select批量更新
HTTP中的重定向和请求的转发
解析json
使用docker安装redis -- 转帖https://blog.csdn.net/weixin_38958597/article/details/106048983
浏览器内输入网址到显示网页全过程及相关问题
go获取客户端ip地址 转自https://blog.csdn.net/Me5201314You/article/details/105739408
转帖--gochannel详解
Copyright © 2011-2022 走看看