1. 程式人生 > 實用技巧 >AI火了!盤點2019全國哪些大學開設了人工智慧專業

AI火了!盤點2019全國哪些大學開設了人工智慧專業

表單

HTML 表單用於收集不同型別的使用者輸入。

初識表單

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登入註冊</title>
</head>
<body>
<h1>註冊</h1>

<!--表單form
action:表單提交的位置,可以時網站,也可以是一個請求處理地址
get方式提交:可以在url中看到我們提交的資訊,不安全,搞笑
post方式:比較安全,傳輸大檔案
-->

<form action="1.我的第一個網頁.html" method="get">
<!--   文字輸入框 -->
    <p>名字:<input type="text" name = "username"></p>
    <p>密碼: <input type="password" name="pwd"></p>
    <p>
    <input type="submit">
    <input type="reset">
    </p>
</form>
</body>
</html>

表單元素格式

屬性 說明
type 指定元素的型別。text、password、checkbox、radio、reset、file、hidden、image、和button,預設為text
name 指定表單元素的名稱
value 元素的初始值。type為radio時必須指定一個值
size 指定表單元素的初始寬度。當type為text或password時,表單元素的大小以字元為單位。對於其他型別,寬度以畫素為單位。
maxlength type為text或password時,輸入的最大字元數
checked type為radio或checkbox時,指定按鈕是否是被選中

1.單選框

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<p>
    <input type="radio" value="boy" name="sex">男
    <input type="radio" value="girl" name="sex">女
</p>

</body>
</html>

2.多選框

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<form action="1.我的第一個網頁.html" method="get">
    <p>名字: <input type="text" name = "username"></p>
    <p>密碼: <input type="password" name="pwd"></p>

    <!--    多選框
    input tpye = “checkbox”
    -->
    <p>
        <input type="checkbox" value="Java" name="Language">Java
        <input type="checkbox" value="C++" name="Language">C++
        <input type="checkbox" value="python" name="Language">python
        <input type="checkbox" value="Go" name="Language">Go
    </p>

    <p>
        <input type="submit">
        <input type="reset">
    </p>

</form>
</body>
</html>

3.按鈕

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<form action="1.我的第一個網頁.html" method="get">
    <p>名字: <input type="text" name = "username"></p>
    <p>密碼: <input type="password" name="pwd"></p>

    <!--    按鈕
    input type="button"普通按鈕
    input type="image"影象按鈕
    input type="submit"提交按鈕
    input type="reset"重置按鈕
    -->
    <p>
        <input type="button" name="btn1" value="點這裡">
        <input type="image" src="../resource/image/1.jpg" width="100" height="150">
    </p>


    <p>
        <input type="submit">
        <input type="reset">
    </p>

</form>
</body>
</html>

4.下拉框

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<form action="1.我的第一個網頁.html" method="get">
    <p>名字: <input type="text" name = "username"></p>
    <p>密碼: <input type="password" name="pwd"></p>


    <!--    下拉框,列表框-->
    <p>
        <select name="Language">
            <option value="Java" selected>Java</option>
            <option value="C++">C++</option>
            <option value="python">python</option>
            <option value="Go">Go</option>
        </select>
    </p>
    <p>
        <input type="submit">
        <input type="reset">
    </p>

</form>
</body>
</html>

5.文字域

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<form action="1.我的第一個網頁.html" method="get">
    <p>名字: <input type="text" name = "username"></p>
    <p>密碼: <input type="password" name="pwd"></p>


<!--文字域-->
    <p>反饋:
        <textarea name="textarea"  cols="50" rows="10">Text</textarea>
    </p>

    <p>
        <input type="submit">
        <input type="reset">
    </p>

</form>
</body>
</html>

6.檔案域

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<form action="1.我的第一個網頁.html" method="get">
    <p>名字: <input type="text" name = "username"></p>
    <p>密碼: <input type="password" name="pwd"></p>

<!--檔案域-->
<p>
    <input type='file' name="files">
    <input type="button" value="上傳" name="upload">
</p>

    <p>
        <input type="submit">
        <input type="reset">
    </p>

</form>
</body>
</html>

7.其他功能性標籤

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<form action="1.我的第一個網頁.html" method="get">
    <!--
    功能性表單
    -->
    <p>郵箱:
        <input type="email" name="email">
    </p>

    <p>URL:
        <input type="url" name="url">
    </p>

    <p>商品數量:
        <input type="number" name="num" max="100" min="10" step=1>
    </p>

    <p>滑塊
        <input type="range" name="voice" min="0" max="100" step="1">
    </p>

    <p>搜尋
        <input type="search" name="search">
    </p>
</form>
</body>
</html>

8.增強滑鼠可用性

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<form action="1.我的第一個網頁.html" method="get">

    <!--   文字輸入框 -->
    <p>名字: <input type="text" name = "username"></p>
    <p>密碼: <input type="password" name="pwd"></p>
    <!--    增強滑鼠可用性
        點文字可以鎖定框
    -->
    <label for="mark">點我</label>
    <input type="text" id="mark">

    <p>
        <input type="submit">
        <input type="reset">
    </p>

</form>
</body>
</html>

表單的應用

  • hidden:隱藏
  • readonly:只讀
  • disabled:禁用
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<form action="1.我的第一個網頁.html" method="get">

    <!--   文字輸入框 -->
    <p>名字: <input type="text" name = "username" value="admin" readonly></p>
    <p>密碼: <input type="password" name="pwd" value="123456" hidden></p>

    <p>
        <input type="submit" disabled>
        <input type="reset">
    </p>

</form>
</body>
</html>

表單初級驗證

為了減輕伺服器的負擔和安全性,需要在前端對收到的資料進行驗證

  • placeholder:提示資訊
  • required:非空判斷
  • pattern:正則表示式
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<form action="1.我的第一個網頁.html" method="get">

    <!--   文字輸入框 -->
    <p>名字: <input type="text" name = "username" placeholder="請輸入使用者名稱" required></p>
    <p>密碼: <input type="password" name="pwd"></p>
    <p>郵箱:
        <input type="text" name="email" pattern="^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$">
    </p>
    <p>
        <input type="submit">
        <input type="reset">
    </p>

</form>
</body>
</html>