HTML5验证及日期显示

以前忽略了HTML5的强大功能,谁知有了它数据大部分都不需要自己验证,显示日历也不需要插件啦,一些小功能分享给大家

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

<!DOCTYPE HTML>
<html>
<body>
<form action="#" method="get">
E-mail: <input type="email" name="user_email"/><br />
<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>

posted @ 2013-07-04 15:22  ice&sww  阅读(665)  评论(0编辑  收藏  举报