OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <meta charset=utf-8> |
| 3 <title>Selector: pseudo-classes (:valid, :invalid)</title> |
| 4 <link rel="author" title="Denis Ah-Kang" href="mailto:denis@w3.org" id=link1> |
| 5 <link rel=help href="https://html.spec.whatwg.org/multipage/#pseudo-classes" id=
link2> |
| 6 <script src="../../../../../../resources/testharness.js"></script> |
| 7 <script src="../../../../../../resources/testharnessreport.js"></script> |
| 8 <script src="utils.js"></script> |
| 9 <div id="log"></div> |
| 10 <div id='simpleConstraints'> |
| 11 <input type=text id=text1 value="foobar" required> |
| 12 <input type=text id=text2 required> |
| 13 </div> |
| 14 <div id='FormSelection'> |
| 15 <form id=form1> |
| 16 <input type=text id=text3 value="foobar" required> |
| 17 </form> |
| 18 <form id=form2> |
| 19 <input type=text id=text4 required> |
| 20 </form> |
| 21 </div> |
| 22 <div id='FieldSetSelection'> |
| 23 <fieldset id=fieldset1> |
| 24 <input type=text id=text5 value="foobar" required> |
| 25 </fieldset> |
| 26 <fieldset id=fieldset2> |
| 27 <input type=text id=text6 required> |
| 28 </fieldset> |
| 29 </div> |
| 30 <div id='patternConstraints'> |
| 31 <input type=text id=text7 value="AAA" pattern="[0-9][A-Z]{3}"> |
| 32 <input type=text id=text8 value="0AAA" pattern="[0-9][A-Z]{3}"> |
| 33 </div> |
| 34 <div id='numberConstraints'> |
| 35 <input type=number id=number1 value=0 min=1> |
| 36 <input type=number id=number2 value=1 min=1> |
| 37 </div> |
| 38 |
| 39 <script> |
| 40 testSelector("#simpleConstraints :valid", ["text1"], "':valid' matches element
s that satisfy their constraints"); |
| 41 |
| 42 testSelector("#FormSelection :valid", ["form1", "text3"], "':valid' matches fo
rm elements that are not the form owner of any elements that themselves are cand
idates for constraint validation but do not satisfy their constraints"); |
| 43 |
| 44 testSelector("#FieldSetSelection :valid", ["fieldset1", "text5"], "':valid' ma
tches fieldset elements that have no descendant elements that themselves are can
didates for constraint validation but do not satisfy their constraints"); |
| 45 |
| 46 testSelector("#patternConstraints :valid", [ "text8" ], "':valid' matches elem
ents that satisfy their pattern constraints"); |
| 47 |
| 48 testSelector("#numberConstraints :valid", [ "number2" ], "':valid' matches ele
ments that satisfy their number constraints"); |
| 49 |
| 50 |
| 51 testSelector("#simpleConstraints :invalid", ["text2"], "':invalid' matches ele
ments that do not satisfy their simple text constraints"); |
| 52 |
| 53 testSelector("#FormSelection :invalid", ["form2", "text4"], "':invalid' matche
s form elements that are the form owner of one or more elements that themselves
are candidates for constraint validation but do not satisfy their constraints"); |
| 54 |
| 55 testSelector("#FieldSetSelection :invalid", ["fieldset2", "text6"], "':invalid
' matches fieldset elements that have of one or more descendant elements that th
emselves are candidates for constraint validation but do not satisfy their const
raints"); |
| 56 |
| 57 testSelector("#patternConstraints :invalid", ["text7"], "':invalid' matches el
ements that do not satisfy their pattern constraints"); |
| 58 |
| 59 testSelector("#numberConstraints :invalid", ["number1"], "':invalid' matches e
lements that do not satisfy their number constraints"); |
| 60 |
| 61 document.getElementById("text7").value="0BBB"; |
| 62 testSelector("#patternConstraints :valid", [ "text7", "text8" ], "':valid' mat
ches new elements that satisfy their constraints"); |
| 63 testSelector("#patternConstraints :invalid", [], "':invalid' doesn't match new
elements that satisfy their constraints"); |
| 64 |
| 65 document.getElementById("text8").value="BBB"; |
| 66 testSelector("#patternConstraints :valid", ["text7"], "':valid' doesn't match
new elements that do not satisfy their constraints"); |
| 67 testSelector("#patternConstraints :invalid", ["text8"], "':invalid' matches ne
w elements that do not satisfy their constraints"); |
| 68 </script> |
OLD | NEW |