Single-line text fields and password fields in HTML basic tutorial forms

Single line text field

Syntax format:

<input type = “text” attribute = “ Value" />

Common attributes

  • name: the name of the text box. The naming rules are: it can contain letters, numbers, and underscores, and can only start with a letter.

  • type: Type of form element.

  • value: The value in the text box.

  • size: The length of the text box, in "characters".

  • maxLength: The maximum number of characters that can be entered. If it exceeds the number, it cannot be entered.

  • readonly: Read-only attribute. It can be selected but cannot be modified. For example: readonly = “readonly”

  • disabled: Disabled attribute. It cannot be selected or modified. For example: disabled = “disabled”

##Example:

<input type="text" name="username" />


Single line password field

##Syntax format:

< input type = “password” attribute = “value” />

Common attributes

    name: the name of the password box. The naming rules are: it can contain letters, numbers, and underscores, and can only start with a letter.
  • type: Type of form element.
  • value: The value in the element.

  • size: The length of the element, in "characters".
  • maxLength: The maximum number of characters that can be entered. If it exceeds the number, it cannot be entered.
  • readonly: Read-only attribute. It can be selected but cannot be modified. For example: readonly = “readonly”
  • disabled: Disabled attribute. It cannot be selected or modified. For example: disabled = “disabled”


Example:

<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>用户注册</title>
    </head>
    <body>
        <font size="5" color="red">欢迎注册php.cn</font>
        <form name="user" method="get" action="" >
            用户名:<input type="text" name="username" value="请输入您的用户名" maxLength="6"/>
            <br/>
            密码:<input type="password" name="userpwd" maxLength="6"/>
            <br/>
            <input type="submit" value="提交信息"/>
        </form>
    </body>
</html>

You can also enter other attributes to view the results

Continuing Learning
||
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>用户注册</title> </head> <body> <font size="5" color="red">欢迎注册php.cn</font> <form name="user" method="get" action="" > 用户名:<input type="text" name="username" value="请输入您的用户名" maxLength="6"/> <br/> 密码:<input type="password" name="userpwd" maxLength="6"/> <br/> <input type="submit" value="提交信息"/> </form> </body> </html>
submitReset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!