单选按钮 设置required属性无法进行非空验证
先看代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>demo</title>
<style>
input[type="submit"]{
width: 120px;
height: 40px;
border: 0;
background-color: antiquewhite;
}
input[type="submit"]:hover{
background-color: beige;
}
</style>
</head>
<body>
<form action="#" method="post">
<label><input type="radio" required />高中</label>
<label><input type="radio" required />大专</label>
<label><input type="radio" required />本科</label>
<label><input type="radio" required />硕士研究生</label>
<label><input type="radio" required />博士及以上</label>
<br />
<input type="submit" value="提交" />
</form>
</body>
</html>
提交数据时并没有进行非空验证。
正确代码为:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>demo</title>
<style>
input[type="submit"]{
width: 120px;
height: 40px;
border: 0;
background-color: antiquewhite;
}
input[type="submit"]:hover{
background-color: beige;
}
</style>
</head>
<body>
<form action="#" method="post">
<label><input type="radio" name="q1" required />高中</label>
<label><input type="radio" name="q1" required />大专</label>
<label><input type="radio" name="q1" required />本科</label>
<label><input type="radio" name="q1" required />硕士研究生</label>
<label><input type="radio" name="q1" required />博士及以上</label>
<br />
<input type="submit" value="提交" />
</form>
</body>
</html>
原因:
单项选择的实现是通过对多个单选按钮设置同样的name属性值和不同的选项值。例如,使用两个单选按钮,设置这两个控件的name值为sex,选项值一个为女,一个为男,从而实现从性别中选择一个的单选功能。
单选按钮有一个重要的属性checked,用来设置或返回单选按钮的状态。一组name值相同的单选按钮中,如果其中一个按钮的checked属性被设置为true,则其他按钮的checked属性值就默认为false。
单选按钮 设置required属性无法进行非空验证的更多相关文章
- JavaWeb 学习008-今日问题(非空验证尚未解决) 2016-12-2
1. 学生模块list页面 不能正常跳转 说是找不到stuid属性,但是我在entity里面和数据库建表的属性就是stuid:Grade模块代码一样,却可以正常运行 这是什么问题? <c:for ...
- JS非空验证及邮箱验证
非空验证 <body> <table> <tr> <td>姓名:</td> <td><input type="t ...
- Atitit 验证 数字验证 非空验证的最佳算法 h5
Atitit 验证 数字验证 非空验证的最佳算法 h5 <td><select class="searchBox-select" style=" ...
- JS-表单非空验证
JavaScript 表单验证 JavaScript 可用来在数据被送往服务器前对 HTML 表单中的这些输入数据进行验证. 实例:1.用户名的非空验证代码如下: <head> <m ...
- select标签非空验证,第一个option value=""即可
select标签非空验证,第一个option value=""即可,否则不能验证
- 非空验证(源代码Java版)
import java.util.Map; /** * 非空验证工具类 */ public class UntilEmpty { /** * @see: 验证string类型的是否为空 */ publ ...
- php非空验证
我想说这种方法是不是很常用的非空验证,现在的普遍使用的是javascript来验证非空,但是作为学习php的一些知识点,还是可以看看的. 先来看看commit.php中的方法 <?php $db ...
- .NET开源工作流RoadFlow-Bug修改-1.8.2表单验证时ueditor编辑非空验证无效
RoadFlow生成的表单,Ueditor编辑器不能进行非空验证的BUG修改: 1.修改控制器:WorkFlowFormDesignerController红框处: 2.修改js文件:Scripts/ ...
- iview 表单非空验证
rules: { title: [ {required: true, message: '请填写栏目名称', trigger: 'blur'} ], desc: [ {required: true, ...
随机推荐
- doctype的意思
<!DOCTYPE HTML>这句话在整个网页的最上头,意思是这个网页是一个用html5语法写的,因为还有html4和xhtml等语法. 为了兼容一些旧的页面,浏览器设置了两种解析模式:1 ...
- AtCoder Beginner Contest 153 题解
目录 AtCoder Beginner Contest 153 题解 A - Serval vs Monster 题意 做法 程序 B - Common Raccoon vs Monster 题意 做 ...
- Computer Abstractions
计算机系统结构的概述 (MOOC:计算机系统设计) 组成: 硬件:CPU +MM(主存)+I/O(输入/输出) 软件:系统软件+应用软件 层次结构: 发展简史: 第一代:真空管 ·ENIAC ·冯诺 ...
- java基础(四)之this的使用
作用: 1.使用this调用成员变量和成员函数2.使用this调用构造函数 Person.java: class Person{ String name; //成员变量 void talk(Strin ...
- adb 无线连接手机设备
连接语法: $ adb connect ip:port 断开连接: $ adb disconnect ip:port 可能遇到问题:unable to connect to 192.168.199.2 ...
- 关于Excute()方法,与in参数连用
DECLARE @tempTbl TABLE(OrderNo VARCHAR(50)) DECLARE @orderNos VARCHAR(4000) SET @orderNos='''3f1a82c ...
- c++ char转换成string
第一种:利用赋值号直接赋值 ; string b = a; /* 错误.因为string是一个指针,存储的值是所指向的地址,而char型存储的是内容,所以不可以直接用赋值号赋值 */ const ch ...
- 银行业务队列简单模拟(队列queue)
设某银行有A.B两个业务窗口,且处理业务的速度不一样,其中A窗口处理速度是B窗口的2倍 —— 即当A窗口每处理完2个顾客时,B窗口处理完1个顾客.给定到达银行的顾客序列,请按业务完成的顺序输出顾客序列 ...
- Bayer Pattern
在刚加入工作的时候,听到最多的就是RGGB Bayer Pattern.在之前的接触中,一直默认一张图片的每个像素点有RGB三个分量,那“RGGB Bayer Pattern”究竟是什么意思.在网上查 ...
- 洛谷P1433 吃奶酪
#include<iostream> #include<math.h> using namespace std ; ; int n; bool st[N]; double x[ ...