在HTML5中,表单新增了一些属性,input标签也有了更多的type类型,有些实现了js才能实现的特效,但目前有些浏览器不能全部支持。下面是一些h5在表单和input标签上的一些改动。

<!DOCTYPE html>
<html>
<head>
<title>表单测试</title>
<meta charset="utf-8" />
<!-- 在不支持h5的浏览器中,可以用CSS样式进行改写 -->
<style>
input[type="search"] {-webkit-appearance: textfield;}
</style>
<script type="text/javascript" src="jquery-1.8.3.min.js"></script>
</head>
<body>
<!-- 在html5中,input标签可以不写在form里,但要给form一个id(如:login),然后在input中加一个form="login"属性。
如果在同一表单中,做操作时,可以在input中加入formaction="1.php"属性将表单提交到不同的PHP处理文件中。
也可以增加formmethod="get"属性使不同的文本框提交的方法不同。-->
<!-- 如果要使整个表单验证失效,可以再form中加入novalidate属性;也可以在input中加入formnovalidate属性,使单个文本框失效(不可以与required一起使用) -->
<form action="demo.php">

<!-- 当文本框是text或者textarea类型时,在未输入状态下,使用placeholder属性可以显示输入提示 -->
TEXT:<input type="text" placeholder="请输入用户名" name="username"/><br/>
<!-- search类型的input用来输入搜索关键词
autofocus属性用来自动获取光标焦点,但一个页面只能有一个。
input标签中的list属性,用于给出下拉选择(类似于select),要与datalist元素一起使用,datalist设置一个id值,
input中加入list="id值即可"-->
SEARCH:<input list="listtest" type="search" autofocus name="ser"/><br/>
<datalist >
</form>
</body>
</html>

相关文章:

  • 2021-12-30
  • 2021-11-29
  • 2021-12-13
  • 2021-08-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-06-27
  • 2022-12-23
  • 2021-06-10
  • 2021-12-27
  • 2022-12-23
相关资源
相似解决方案