[whatwg] select element should have a required attribute

On 6/19/10, Ashley Sheridan <ash at ashleysheridan.co.uk> wrote:
> On Fri, 2010-06-18 at 13:34 -0700, Garrett Smith wrote:
>
>> On 6/18/10, Garrett Smith <dhtmlkitchen at gmail.com> wrote:
>> > On 6/18/10, Ashley Sheridan <ash at ashleysheridan.co.uk> wrote:
>> >> On Fri, 2010-06-18 at 11:35 +0200, Mounir Lamouri wrote:
>> >>
>>
>> [...]
>> >
>> > Implementations vary on actual behavior. See also:
>> > https://bug-20184-attachments.webkit.org/attachment.cgi?done=true&id=22519
>> >

That is the wrong URL to begin the test; instead, the following URL
must be used:
https://bug-20184-attachments.webkit.org/attachment.cgi?id=22519

Looking closer, that test is no good. Doesn't run in IE anyway. Since
I made it, it's my fault and so I've attached a simpler test bug. The
simpler test is still not that good because it tests two things:
  1) is a SELECT with no name successful?
  2) is a disabled, selected OPTION in a SELECT successful?

 but it's not as bad as the other test, which did some complicated
onload stuff that made it hard to understand.

This test is also posted below, though with using "block" instead of
"inline-block" to show the results in more browsers.

>>
>> The actual bug:
>> https://bugs.webkit.org/show_bug.cgi?id=20184
>>
>> Garrett
>
>
> I'd expect a disabled control to still send the value it would have sent
> if it weren't disabled. A select element without a name shouldn't be
> sent, which I believe is the case with all form elements not given a
> name?
>

Controls that are disabled cannot be successful. Browser behavior
varies on what happens when a SELECT has a disabled OPTION selected.

To be successful, all form controls must have a name. FORM element
itself does not need to be given a name.

http://www.w3.org/TR/html401/interact/forms.html#h-17.3
http://localhost:8020/jstest/suc.html?wrong=disabled&done=Submit
A better example, to be sent from a web server below, the results are:

PASS:
   IE8, 9b, FF 2, FF 3.6,

FAIL:
   IE7 an below, Opera 10.5, Safari 4.

<!DOCTYPE HTML>
<html lang="en">
<head>
	<title>Submit</title>
	<style type="text/css">
	h2 {
		display: none;
	}
	#pass {
		background: #0f0;
	}
	#fail {
		background: Red;
	}
	</style>
</head>
<body>
<form action="">
<select><option disabled>invalid</option></select>
<select><option disabled></option></select>
<select name="wrong"><option disabled
selected>disabled</option><option>enabled</option></select>
<input type='submit' id="done" name="done" value="Submit"/>
</form>
<h2 id="pass">PASS</h2>
<h2 id="fail">FAIL</h2>
<script type="text/javascript">
onload =  function() {
	var q = location.search,
		f = document.forms[0],
		m,
		id = document.getElementById('id');
	
	if(!/done/.test(q)) return;
	
	// Options with "disabled" or "invalid" value
	// are are failures here.
	if(q && /invalid|disabled/.test(q)) {
	  document.getElementById("fail").style.display = "block";
	} else {		
		document.getElementById("pass").style.display = "block";
	}
}
</script>
</body>
</html>

Garrett

Received on Saturday, 19 June 2010 11:46:16 UTC