test_select_validation.html (1278B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=942321 5 --> 6 <head> 7 <title>Test for Bug 942321</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 <script src="/tests/SimpleTest/EventUtils.js"></script> 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 11 </head> 12 <body> 13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=942321">Mozilla Bug 942321</a> 14 <p id="display"></p> 15 <form id="form" href=""> 16 <select required id="testselect"> 17 <option id="placeholder" value="" selected>placeholder</option> 18 <option value="test" id="actualvalue">test</option> 19 <select> 20 <input type="submit" /> 21 </form> 22 <script class="testbody" type="text/javascript"> 23 /** Test for Bug 942321 */ 24 var option = document.getElementById("actualvalue"); 25 option.selected = true; 26 is(form.checkValidity(), true, "Select is required and should be valid"); 27 28 var placeholder = document.getElementById("placeholder"); 29 placeholder.selected = true; 30 is(form.checkValidity(), false, "Select is required and should be invalid"); 31 32 placeholder.value = "not-invalid-anymore"; 33 is(form.checkValidity(), true, "Select is required and should be valid when option's value is changed by javascript"); 34 </script> 35 </pre> 36 </body> 37 </html>