H5新增表单属性

表单新增type属性:
邮箱:<input type="email"/>
电话:<input type="tel"/>
网址:<input type="url"/>
数量:<input type="number" value="50" max="100" min="0"/>
查找:<input type="search"/>
范围:<input type="range"/>
颜色:<input type="color"/>
时间:<input type="time"/>
日期:<input type="date"/>
时间日期:<input type="datetime-local"/>
月份:<input type="month"/>
星期:<input type="week"/>

表单新增其他属性:
提示文本:placeholder
自动获取焦点:autofocus
自动完成:autocomplete //on:打开 off:关闭
必须输入:required
正则表达式验证:pattern
选择多个文件:multiple
指定表单id:form

新增表单事件:
oninput:监听当前指定元素的内容改变
oninvalid:当验证不通过时触发

演示代码

<!DOCTYPE html>
<html>
	<head>
		<title>新增表单type属性</title>
		<meta charset="utf-8" />
	</head>
	<body>
		<form id="Myform">
			<!-- 提供默认电子邮箱的完整验证 -->
			邮箱:<input type="email" name="Email" /><br/>
			<!-- 在移动端打开数字键盘 -->
			电话:<input type="tel" name="PhoneNumber" required /><br/>
			<!-- 验证输入合法的网站,必须包含http:// 
				·value:默认值
				·max:最大值
				·min:最小值
			-->
			网址:<input type="url" name="Url" /><br/>
			<!-- 只能输入数字或小数点 -->
			数量:<input type="number" min="0" max="100" value="50" name="Num" /><br/>
			<!-- 提供更人性化的输入体验 -->
			查找:<input type="search" name="Search" /><br/>
			<!-- 范围 -->
			范围:0<input type="range" min="0" max="100" value="50" name="Range"/>100<br/>
			<!-- 颜色选择 -->
			颜色:<input type="color" name="Color" /><br/>
			<!-- 时分秒 -->
			时间:<input type="time" name="Time" /><br/>
			<!-- 年月日 -->
			日期:<input type="date" name="Date" /><br/>
			<!-- 月 -->
			月份:<input type="month" name="Month" /><br/>
			<!-- 星期 -->
			星期:<input type="week" name="Week" /><br/>
			<!-- 提交 -->
			<input type="submit" value="提交" /><br/>
			<!-- 年月日时分秒 -->
			日期时间:<input type="datetime-local" name="Datetime" form="Myform"/><br/>
		</form>
	</body>
</html>

效果截图

发布了116 篇原创文章 · 获赞 20 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/sm20170867238/article/details/92830161