表单相关的新增

suaxi
2024-03-03 / 0 评论 / 15 阅读 / 正在检测是否收录...

1. 表单控件属性

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>新增的表单控件属性</title>
</head>
<body>
    <form action="">
        账号:<input 
                type="text" 
                name="account" 
                placeholder="请输入账号" 
                required 
                autofocus 
                autocomplete="on"
                pattern="\w{6}"
              >
        <br>
        密码:<input type="password" name="pwd" placeholder="请输入密码" required>
        <br>
        性别:
            <input type="radio" value="male" name="gender" required>男
            <input type="radio" value="female" name="gender">女
        <br>
        爱好:
            <input type="checkbox" value="smoke" name="hobby">抽烟
            <input type="checkbox" value="drink" name="hobby" required>喝酒
            <input type="checkbox" value="perm" name="hobby">烫头
        <br>
        其他:<textarea name="other" placeholder="请输入" required></textarea>
        <br>
        <button>提交</button>
    </form>
</body>
</html>

2. input新增的type属性值

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>input新增的type属性值</title>
</head>
<body>
    <form action="" novalidate>
        邮箱:<input type="email" name="email" required>
        <br>
        网址:<input type="url" name="url">
        <br>
        数值:<input type="number" name="number" step="2" max="100" min="10" required>
        <br>
        搜索:<input type="search" name="keyword">
        <br>
        电话:<input type="tel" name="tel">
        <br>
        范围:<input type="range" name="range" max="100" min="10">
        <br>
        颜色:<input type="color" name="color">
        <br>
        日期:<input type="date" name="date">
        <br>
        月份:<input type="month" name="month">
        <br>
        周:<input type="week" name="week">
        <br>
        时间:<input type="time" name="time1">
        <br>
        日期+时间:<input type="datetime-local" name="time2">
        <br>
        <button type="submit">提交</button>
    </form>
</body>
</html>
0

评论 (0)

取消