超级实习生计划学习打卡—HTML5新增表单控件属性

HTML5新增表单控件属性

HTMML5新增表单标签主要针对input的type属性值,具体属性值描述如下:

1. email

email属性指的是邮箱地址,可以自动校验

<input type="email">

2. date、month、week、time、datetime

日期选择:date:选取年月日。month:选取年月。week:选择周和年。time:选取时间。datetime:选取时间、年月日。

<input type="date | month | week | time | datetime">

3. url

url属性可使输入框内输入http地址,可自动校验。

<input type="url">

4. range

range是用作滑块标签属性,必须输入一定范围内的数值。

<input type="range">

5. number

number属性使表单只能输入数字,表单通过min、max属性可以设置最小最大值。

<input type="number" min="0" max="3">

6. tel

tel限制输入框内的值为正确的电话号码格式

<input type="tel">

7. search

search用作搜索框,应用非常广泛,与text的区别是有值的时候会有清空按钮

<input type="search">

8. HTML5新增的表单控件属性案例

 

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>表单作业1</title>
  <style>
    *{
      margin: 0;
      padding: 0;
    }
    body {
      background-color: #00CCFF;
    }
    form {
      width: 500px;
      height: 600px;
      margin: 0 auto;
      background-color: #fff;
      padding: 25px;
      margin-top: 10px;
    }
    h1 {
      color: #FA9C00;
      margin-bottom: 6px;
    }
    h3 {
      margin-bottom: 12px;
    }
    input {
      width: 500px;
      box-sizing: border-box;
      padding: 16px;
      margin-bottom: 15px;
      font-size: 14px;
    }
    textarea {
      width: 500px;
      box-sizing: border-box;
      padding: 16px;
      margin-bottom: 15px;
      font-size: 14px;
      resize: none;
    }
    input:last-of-type {
      margin-top: 10px;
      color: #fff;
      background-color: #00CCFF;
      border: none;
      font-size: 24px;
    }
  </style>
</head>
<body>
  <form action="">
    <h1>Quick Contanct</h1>
    <h3>Contact us today,and get reply with in 24 hours!</h3>
    <input type="name" placeholder="Your Name" autofocus required>
    <input type="email" placeholder="Your Email Address" required>
    <input type="tel" name="tel" id="tel" placeholder="Phone number" required>
    <input type="url" name="url" id="url" placeholder="Your web site start width http://" required>
    <!-- <input type="t"> -->
    <textarea name="" id="" cols="60" rows="7" placeholder="Type Your Message Here..."></textarea>
    <input type="submit" name="sub" id="sub" value="Submit">
  </form>
</body>
</html>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是微信小程序制作学习计划打卡的代码示例: 1. 在小程序的页面中添加一个表单,包括计划名称、学习时长、完成情况等字段。 ```html <form bindsubmit="formSubmit"> <label>计划名称</label> <input type="text" name="planName" placeholder="请输入计划名称"> <label>学习时长</label> <input type="text" name="studyTime" placeholder="请输入学习时长"> <label>完成情况</label> <select name="isFinished"> <option value="0">未完成</option> <option value="1">已完成</option> </select> <button type="submit">提交打卡</button> </form> ``` 2. 在小程序的 js 文件中添加表单提交的事件处理函数,将用户输入的数据发送到服务器保存。 ```javascript Page({ formSubmit: function(e) { wx.request({ url: 'https://api.example.com/plan/daka', method: 'POST', data: e.detail.value, success: function(res) { console.log(res.data) // 提交成功后跳转到打卡记录列表页 wx.navigateTo({ url: '/pages/record/list' }) } }) } }) ``` 3. 在服务器端编写接收表单数据的 API,并保存到数据库中。 ```javascript const express = require('express') const bodyParser = require('body-parser') const app = express() app.use(bodyParser.json()) app.post('/plan/daka', (req, res) => { const planName = req.body.planName const studyTime = req.body.studyTime const isFinished = req.body.isFinished // 将数据保存到数据库中 // ... res.json({ success: true }) }) app.listen(3000, () => { console.log('Server is running on port 3000') }) ``` 以上是一个简单的微信小程序制作学习计划打卡的示例,具体实现方式可以根据自己的需求进行调整和完善。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值