blob: 25fb6bb9fbf7420631e47858c687f75ab862101c [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<title>required attribute JS set</title>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<input id="input" name="victim" />
<textarea id="textarea" name="victim"></textarea>
<select id="select" name="victim">
<option value="" selected />
<option value="X">X</option>
</select>
<script language="JavaScript" type="text/javascript">
function requiredFor(id) {
return document.getElementById(id).required;
}
description("There are three form control elements below, all optional. They're set as required via required DOM attribute.");
v = document.getElementsByName("victim");
debug("Before set:");
shouldBeFalse('requiredFor("input")');
shouldBeFalse('requiredFor("textarea")');
shouldBeFalse('requiredFor("select")');
debug("");
v[0].required = true;
v[1].required = true;
v[2].required = true;
debug("After set:");
shouldBeTrue('requiredFor("input")');
shouldBeTrue('requiredFor("textarea")');
shouldBeTrue('requiredFor("select")');
debug("");
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>