-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
  • 15,341
  • 32
  • 94
  • 121

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,080
  • 6
  • 12
0

Use the checked attribute:

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

JSFiddle Demo

Jacob G
  • 13,762
  • 3
  • 47
  • 67
0

Just use the 'checked' property

<input type='checkbox' checked>

OR

<input type='checkbox' checked='true'>
atmd
  • 7,430
  • 2
  • 33
  • 64
0
<input name="validation" type="checkbox" checked />Validation

Add attribute checked to the input

indubitablee
  • 8,136
  • 2
  • 25
  • 49