In the last article we learned:
- Input type Reset
- Input type Password
- Input type Color
- Input type Date
- Input type Email
- Input type Checkbox
Including the first 3 input fields learned in the first article about HTML forms, now we can use 9 various types of input fields in our forms. There are more fields, some of which are not very important but you can check all other fields on Internet, but what we have learned about input fields is more than enough.
Now let's see some input attributes so that we can customise our inputs.
The value Attribute
It is used to specify the initial value of an input field.
<input type="text" name="lastname" value="Ronaldo">
The readonly Attribute
It is used to specify that input field can not be edited that is it is fixed.
<input type="text" name="lastname" value="Ronaldo" readonly>
The disabled Attribute
It is used to disable specific input field. The disabled input field can not be clicked or used. Its value will not be sent while submitting form.
<input type="text" name="lastname" value="Ronaldo" disabled>
The size Attribute
It specifies size of input field in number of characters. Default is 20 characters.
<input type="text" name="lastname" value="Ronaldo" size="30">
The maxlength Attribute
It specifies maximum allowed length for the input field.
<input type="text" name="lastname" maxlength="30">
The autocomplete Attribute
This HTML5 special attribute enables browser to automatically complete input based on previously entered values.
<input type="email" name="mymail" autocomplete="on">
The min and max Attributes
This attribute is available for folloeing input fields:
- number
- range
- date
<input type="number" name="cameras" min="1" max="4">
<input type="date" name="bday" min="2000-01-01">
The placeholder Attribute
It is used to specify hint in input field or sample input user can enter.
<input type="text" name="myname" placeholder="Enter your name">
The required Attribute
It is used to specify that form can not be submitted without
<input type="text" name="myname" placeholder="Enter your name">
Although I have not shown live code examples, I encourage you to try this example out. The above-mentioned input attributes are more than enough and can be applied to various types of inputs(excluding some special like min and max).
That's all for today. In the next article, we will some more things about forms and will most probably finish HTML forms. Till then #keepCoding.
Comments
Post a Comment