summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/forms/the-input-element/input-labels.html
blob: 77f4d8b31a5131994ee30f27179d02981047a828 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<!DOCTYPE HTML>
<html>
 <head>
  <title>Forms</title>
  <script src="/resources/testharness.js"></script>
  <script src="/resources/testharnessreport.js"></script>
 </head>
 <body>
  <p>
    <h3>input_labels</h3>
  </p>

  <hr>

  <div id="log"></div>

  <form method="post"
      enctype="application/x-www-form-urlencoded"
      action=""
      id="input_form">
    <p><label>Full name:<label>(name)<input name=fn id='input_text1'> <small>Format: First Last</small></label></label></p>
    <p><label>Age: <input name=age type=number min=0 id='input_text2'></label></p>
    <p><label>Post code: <input name=pc> <small>Format: AB12 3CD</small></label></p>
  </form>
  <script>

    var input1 = document.getElementById("input_text1");
    var input2 = document.getElementById("input_text2");

    if (typeof(input1.labels) == "object") {
      if (input1.labels.length == 2 && input2.labels.length == 1) {
        test(function() {
          assert_true(true, "labels attribute is correct.");
        });
      } else {
        test(function() {
          assert_unreached("labels attribute is not correct.");
        });
      }
    } else {
      test(function() {
        assert_unreached("labels attribute is not exist.");
      });
    }

  </script>

 </body>
</html>