我們使用標(biāo)簽,通過(guò)將password賦值給type屬性,在HTML表單中接收密碼輸入。當(dāng)我們輸入密碼時(shí),它會(huì)立即隱藏字符。這也是一個(gè)單行文本輸入。
語(yǔ)法
<form> <input type="password" name="name… " value=" ">Male </form>
登錄后復(fù)制
示例 1
一個(gè)在HTML中實(shí)現(xiàn)密碼輸入的示例如下:
<!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>
登錄后復(fù)制
示例 2
下面給出了另一個(gè)將輸入作為密碼的示例。您可以嘗試運(yùn)行以下代碼 –
<!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>
登錄后復(fù)制
以上就是我們?nèi)绾卧贖TML表單中輸入密碼?的詳細(xì)內(nèi)容,更多請(qǐng)關(guān)注www.92cms.cn其它相關(guān)文章!






