1 <!DOCTYPE HTML PUBLIC
"-//IETF//DTD HTML//EN">
4 <title>required attribute JS set
</title>
5 <script src=
"../../resources/js-test.js"></script>
8 <p id=
"description"></p>
9 <div id=
"console"></div>
10 <input id=
"input" name=
"victim" />
11 <textarea id=
"textarea" name=
"victim"></textarea>
12 <select id=
"select" name=
"victim">
13 <option value=
"" selected
/>
14 <option value=
"X">X
</option>
16 <script language=
"JavaScript" type=
"text/javascript">
17 function requiredFor(id
) {
18 return document
.getElementById(id
).required
;
21 description("There are three form control elements below, all optional. They're set as required via required DOM attribute.");
23 v
= document
.getElementsByName("victim");
26 shouldBeFalse('requiredFor("input")');
27 shouldBeFalse('requiredFor("textarea")');
28 shouldBeFalse('requiredFor("select")');
36 shouldBeTrue('requiredFor("input")');
37 shouldBeTrue('requiredFor("textarea")');
38 shouldBeTrue('requiredFor("select")');