What is the value of a checkbox?
Are you curious to know that what is the value of a checkbox?
In this article, we will try to understand
- Does a checkbox content the value attribute? If it contains the value attribute, then where it is? Why the value of a <input type="checkbox"> does not shown to the users?
- What is the default value of checkbox?
- What is the value of unchecked checkbox?
- How to make a checkbox checked by default?
What is the value of a checkbox?
The value attribute of a checkbox contents some text or number that doesn't shown to the users. It returns a string value which represent the value of the value attribute of the input checkbox field.
What is the default value of a checkbox?
The default value of a input checkbox field is on. However, we can change this value according to our needs. (e.g. <input type="checkbox" value="my text">)
What is the value of unchecked checkbox?
The value of a unchecked checkbox is also on. If a checkbox is unchecked when the form is submitted, the value is not submitted to the server at all.
How to make a checkbox checked by default?
Use the checked="" attractive to make a checkbox checked by default. e.g. <input type="checkbox" checked=" ">
Conclusion
In this article, I have explained everything about the value attribute of input type checkbox to you.