HTML FORM INPUT ATTRIBUTES: HTML input attributes contains a set of attributes such as
1. Value attribute
2. Readonly attribute
3. Disabled attribute
4. Size attribute
5. Maxlength attribute
HTML FORM INPUT ATTRIBUTES
Here, we are describing in detail regarding attributes.
1. HTML Value attribute:
The value attribute defines the initial value for an input field.
Example:
<!DOCTYPE html> <html> <body> <h2>Value Attribute</h2> <form action=""> First name:<br> <input type="text" name="firstname" value="Tutorials"> <br> Last name:<br> <input type="text" name="lastname" value="Freshersnow"> </form> </body> </html>
2. HTML Readonly attribute:
This attribute defines that the input is read-only and it cannot be changed.
Example:
<!DOCTYPE html> <html> <body> <h2>Readonly Attribute</h2> <form action=""> First name:<br> <input type="text" name="firstname" value="Tutorials" readonly> <br> Last name:<br> <input type="text" name="lastname" value="Freshersnow"> </form> </body> </html>
3. HTML Disabled attribute:
The disabled attribute defines, the input field is disabled i.e.; the input field cannot be used or changed. The value is not sent when the form is submitted.
Example:
<!DOCTYPE html> <html> <body> <h2>Disabled Attribute</h2> <form action=""> First name:<br> <input type="text" name="firstname" value ="Tutorials" disabled> <br> Last name:<br> <input type="text" name="lastname" value="Freshersnow"> </form> </body> </html>
4. HTML Size attribute:
Size attribute specifies the size of the input field.
Example:
<!DOCTYPE html> <html> <body> <h2>Size Attribute</h2> <form action=""> First name:<br> <input type="text" name="firstname" value="Tutorials" size="40"> <br> Last name:<br> <input type="text" name="lastname"> </form> </body> </html>
5. HTML Maxlength attribute:
This defines the maximum allowed length for an input field.
Example:
<!DOCTYPE html> <html> <body> <h2>Maxlength Attribute</h2> <form action=""> First name:<br> <input type="text" name="firstname" maxlength="10"> <br> Last name:<br> <input type="text" name="lastname"> </form> </body> </html>