-2

I have the following and want to ensure the tick boxes are enabled by default.

<div class="checkbox">
        <label>
          <input name="validation" type="checkbox">Validation
        </label>

        <label>
          <input name="steps" type="checkbox">Steps
        </label>

        <label>
          <input name="subticket" type="checkbox">Subticket
        </label>
  </div>

Whats the best method for achieving this ?

felix001
  • 13,941
  • 29
  • 86
  • 111

4 Answers4

1

You can use checked property with value true i.e. checked="true" or you can use checked only without any value, because by default it will consider true.

<div class="checkbox">
        <label>
          <input name="validation" type="checkbox" checked>Validation
        </label>

        <label>
          <input name="steps" type="checkbox" checked>Steps
        </label>

        <label>
          <input name="subticket" type="checkbox" checked>Subticket
        </label>
  </div>
Swapnil Motewar
  • 1,052
  • 6
  • 11
0

Use the checked attribute:

<label>
  <input name="validation" type="checkbox" checked>Validation
</label>

JSFiddle Demo

Jacob Gray
  • 13,114
  • 3
  • 44
  • 63
0

Just use the 'checked' property

<input type='checkbox' checked>

OR

<input type='checkbox' checked='true'>
atmd
  • 7,260
  • 2
  • 31
  • 63
0
<input name="validation" type="checkbox" checked />Validation

Add attribute checked to the input

indubitablee
  • 7,968
  • 2
  • 24
  • 48