form | Sololearn: Learn to code for FREE!



why we can't use text for the value attribute of checkbox instead of numbers (value=1)?

4/30/2020 5:17:34 PM

Dilini Jayasundara

2 Answers

New Answer


Dilini Jayasundara This is quite a nice question. You can use both number and text for the 'value' attribute of checkbox input. But the thing is it will not render in the screen. This is because checkboxes are rendered in the screen independently. So you just see a rounded box in the screen. However you can use the label tag to do the same! <input type="checkbox" id="cbox" value="Can be anything"> <label for="cbox">Check me</label> You can still get the value from the checkbox by using javascript!


Ok I'll check it. Thank you very much.