如何在 HTML 表單中輸入密碼?
HTML 表單中透過為 type 屬性分配 password 值來使用 <input> 標籤獲取密碼輸入。它在輸入的密碼字元後立即隱藏該字元。這也是單行文字輸入。

語法
<form> <input type="password" name="name… " value=" ">Male </form>
示例 1
實現如何在 HTML 中獲取密碼輸入的一個示例如下:
<!DOCTYPE html> <html> <body> <head> <meta charset="UTF-8"> <meta name="description" content="meta tag in the web document"> <meta name="keywords" content="HTML,CSS"> <meta name="author" content="lokesh"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <p>Branch</p> <form> <input type="password" id="CSE" name="Branch" value="CSE" > <label for="CSE">Enter password</label> <br> <input type="password" name="Branch" value="IT" > <label for="CSE">Re-enter password</label> </form> </body> </html>
示例 2
以下為獲取密碼輸入的另一個示例。你可以嘗試執行以下程式碼 -
<!DOCTYPE html> <html> <body> <head> <title>HTML Forms</title> </head> <p>Add your details:</p> <form> Student Username:<br> <input type="text" name="name"> <br> Password:<br> <input type="password" name="password"> <br> </form> </body> </html>
廣告
資料結構
網路
關係型資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP