I discovered something surprising:
<html>
<head>
<script type="text/javascript">
function f()
{
document.getElementById("h").value++;
document.getElementById("x").value++;
}
</script>
</head>
<body>
<form>
<input type="hidden" name="hidden" id="h" value="5"/>
<input type="text" id="x" value="5"/>
<input name='clear' type='reset' id='clear' value='Clear'>
</form>
<button type="button" onclick="f()">Increment</button>
<button type="button" onclick="alert(document.getElementById('h').value)">Show hidden</button>
</body>
</html>
Trying this in Firefox 4.0.1, clicking clear always resets the text input to 5
, but never resets the hidden field.
I (and others) did not expect this behavior at all: we expected the hidden value to get reset too!
Can anyone point to either documentation or specs that explain why the hidden input is treated differently by the reset button?
Explanations as to why such behavior is desirable are also welcome.