input-labels.html (1274B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <title>Forms</title> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 </head> 8 <body> 9 <p> 10 <h3>input_labels</h3> 11 </p> 12 13 <hr> 14 15 <div id="log"></div> 16 17 <form method="post" 18 enctype="application/x-www-form-urlencoded" 19 action="" 20 id="input_form"> 21 <p><label>Full name:<label>(name)<input name=fn id='input_text1'> <small>Format: First Last</small></label></label></p> 22 <p><label>Age: <input name=age type=number min=0 id='input_text2'></label></p> 23 <p><label>Post code: <input name=pc> <small>Format: AB12 3CD</small></label></p> 24 </form> 25 <script> 26 27 var input1 = document.getElementById("input_text1"); 28 var input2 = document.getElementById("input_text2"); 29 30 if (typeof(input1.labels) == "object") { 31 if (input1.labels.length == 2 && input2.labels.length == 1) { 32 test(function() { 33 assert_true(true, "labels attribute is correct."); 34 }); 35 } else { 36 test(function() { 37 assert_unreached("labels attribute is not correct."); 38 }); 39 } 40 } else { 41 test(function() { 42 assert_unreached("labels attribute is not exist."); 43 }); 44 } 45 46 </script> 47 48 </body> 49 </html>