获得html表单中radio name相同的数组的值 并判断每个选项不能为空
来源:互联网 发布:哈尔滨管家婆软件 编辑:程序博客网 时间:2024/06/06 05:28
<form method="post" action="" onsubmit="return aa()"> {foreach from="$info" item="fee"} <!--问题:-->{$fee.id}、{$fee.question}<br><label class="ui-radiobox" rel="common_user_type"> <input type="radio" name="score{$fee.id}" value="{$fee.a_score}" > A:{$fee.a_choice} </label><label class="ui-radiobox" rel="common_user_type"> <input type="radio" name="score{$fee.id}" value="{$fee.b_score}"> B:{$fee.b_choice} </label> <label class="ui-radiobox" rel="common_user_type"> <input type="radio" name="score{$fee.id}" value="{$fee.c_score}"> C:{$fee.c_choice} </label> <label class="ui-radiobox" rel="common_user_type"> <input type="radio" name="score{$fee.id}" value="{$fee.d_score}"> D:{$fee.d_choice} </label> <br> {/foreach} <input type="submit"></form>
jq代码
<script type="text/javascript"> function aa(){ var err_msg=''; var arr_name=[]; $("input:radio[name^=score]").each(function(){ if (!arr_name[this.name]){ arr_name[this.name]=1; } }); for (name in arr_name) { //alert(name); //score8 score9 score7 score6 //console.log($("input:radio[name="+name+"]").val()); if ($("input:radio[name="+name+"]:checked").length==0) { var names = name.substr(5); //alert(names); err_msg+="第"+names+"题还没选择答案\r\n"; } if (err_msg!="") { alert(err_msg); return false; } }</script>
阅读全文
0 0
- 获得html表单中radio name相同的数组的值 并判断每个选项不能为空
- JS判断提交表单不能为空 等的验证
- jQuery 循环判断radio checkbox 选项不能空
- .net获取name相同的表单值
- JQ获取name相同的radio被选中的值
- php获取form表单中name相同的表单项
- 验证所有的checkbox、radio、text等不能为空
- checkbox和radio的js统一判断为空方法
- 字符串不能为空的判断
- PHP中判断数组是否为空的方法
- PHP中判断数组是否为空的方法
- iOS开发中,数组为空的判断处理
- 数组判断为空的方法改进
- 判断groupbox中所有的edit是否为空,并给出空的哪个edit为空
- 判断groupbox中所有的edit是否为空,并给出空的哪个edit为空(2)
- dedecms添加自定义表单判断表单不能为空解决办法
- 检查数组的每个单元对应的bit位是否相同为0,相同就set
- 如果一张表单中有多个文本框的name属性值相同,action中应怎样处理
- 读整数--leetcode Integer to English Word
- Java JDBC sqlserver连接(增删改)方法二
- 阿里巴巴荣获年度最佳BCM创新实践奖
- 禅道和JIRA大对比
- 自助式商业智能可视化工具,移动BI不是梦
- 获得html表单中radio name相同的数组的值 并判断每个选项不能为空
- github上面MD文件书写格式说明
- 5分钟了解Mockito
- 大众点评数据分析报告
- ios一个可滑动列表式的弹出选择框(封装过的)
- 关于子类和父类之间的方法调用关系
- NOIP2017模拟day1 T3 string splay 置换
- Mybatis缓存
- Linux下Mysql安装及问题