HTML5验证以及日期显示的实现详解

2022-10-20,,,,

1.email输入框,自动验证email有效性。

复制代码代码如下:
<!doctype html>
<html>
<body>
<form action="#" method="get">
e-mail: <input type="email" name="user_email"/>

<input type="submit"/>
</form>
</body>
</html>

2.number数字输入,验证正确,可以设置开始结束位。

复制代码代码如下:
<!doctype html>
<html>
<body>
<form action="#" method="get">
<input type="number" step="5" min="5"max="20" name="number" value="0"/>
<input type="submit"/>
</form>
</body>
</html>

3.url输入框,可以验证url输入的有效性。
<form action="#" method="get"> url: <input type="url" name="user_email"/><br /> <input type="submit"/></form>
4.date pickers (date, month, week, time, datetime, datetime-local)选择框,可以选择日期,时间,月,周。

复制代码代码如下:
<!doctype html>
<html>
<body>
<form action="#" method="get">
date: <input type="date" name="user_email"/>
month : <input type="month" name="user_email"/>
week: <input type="week" name="user_email"/>
time: <input type="time" name="user_email"/>
datetime: <input type="datetime" name="user_email"/>
datetime-local : <input type="datetime-local" name="user_email"/>
<input type="submit"/>
</form>
</body>
</html>

5.datalist输入选择。

复制代码代码如下:
<!doctype html> <html>
<body>
<form action="#" method="get">
webpage: <input type="url" list="url_list"value="fdf" name="user_email"/>
<datalist id="url_list">
<option label="w3school"value="http://www.w3school.com.cn"/>
<option label="microsoft" value="http://www.microsoft.com"/>
</datalist><input type="submit"/>
</form>
</body>
</html>

《HTML5验证以及日期显示的实现详解.doc》

下载本文的Word格式文档,以方便收藏与打印。