04、HTML5新添表单元素、新添form属性、新增input属性

元素说明
output标签定义不同类型的输出
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <!-- oninput 触发事件输出,parseInt()转换成整型-->
    <form action="" oninput="x.value=parseInt(a.value)+parseInt(b.value)">
        <input type="range" id="a">+
        <input type="number" id="b">=
        <output id="x"></output>
    </form>
</body>
</html>

效果图如下:
这里写图片描述

新添form属性

属性说明
autocompleteform或input域名自动完功能:即记得之间输入的内容,能在下面提示
novalidate提交表单时不验证form或者input域
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <form action="demo.php" autocomplete="off" novalidate>
        <p>用户名:<input type="text" name="name1"></p>
        <p>邮箱:<input type="email" name="name2"></p>
        <p><input type="submit"></p>
    </form>
</body>
</html>

新增input属性

属性说明
autofocus页面加载时自动获得焦点
required规定输入域不能为空
placeholder提供一种提示,描述输入域所期待的值
pattern规定验证input域的模式(正则表达式)
height、width仅适用于image类型的input标签的图像高度和宽度
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <form action="demo.php" autocomplete="off" >
        <p>用户名:<input type="text" name="name1" autofocus></p>
        <p>邮箱:<input type="email" name="name2" required></p>
        <p>邮箱:<input type="email" name="name3" placeholder="不能缺少@符号"></p>
        <p>描述:<input type="text" pattern="[a-zA-Z]{3}"></p>
        <p><input type="submit"></p>
        <p>
            <input type="image" src="picture.jpg" width="100" height="100">
        </p>
    </form>
</body>
</html>
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值