Form element attributes min and max are now empty strings rather than null

RESOLVED INVALID

Status

()

defect
RESOLVED INVALID
7 years ago
a month ago

People

(Reporter: john.haller, Unassigned)

Tracking

16 Branch
x86_64
Windows 7
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

7 years ago
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20100101 Firefox/15.0.1
Build ID: 20120905151427

Steps to reproduce:

Here is the sample html, I clicked on "Click to Validate":
<html lang="en-US">
<meta charset="windows-1252">
<script language="JavaScript">

function validate()
{
  var f = document.test;
  var form_length = f.length;
  var errors = "Errors so far\n";
  for (var i = 0; i < form_length; i++) {
    var e = f.elements[i];
    if (e.numeric)
      errors += e.name + "numeric\n";
    if (e.min != null) {
      errors += e.name + "min non-null\n";
      if (e.min == "")
        errors += e.name + "min empty string\n";
    }
    if (e.max != null) {
      errors += e.name + "max non-null\n";
      if (e.max == "")
        errors += e.name + "max empty string\n";
    }
  }
  alert(errors);
  return false;
}
</script>

<body>
Test Form
<br>
<form action = "no such file.php" method="post" name="test" onSubmit="javascript:return isConfirmed('test')"
<center>
Name=<input type="text" name="myname" size=30 maxlength=50>
<br>
<a href="javascript:validate()">Click to validate</a>
<input type="submit" name="sub" value="Submit">
</center>
</form>
</body>
</html>



Actual results:

In FireFox 16.0.1, the following is produced by the alert:
Errors so far:
mynamemin non-null
mynamemin empty string
mynamemax non-null
mynamemax empty string
summin non-null
summin empty string
summax non-null
summax empty string



Expected results:

In Firefox 15.0.1, the following is produced by the alert:
Errors so far:
------------------------------
Because of the change between 15.0.1 and 16.0.1, a web page which worked since 1995 no longer works. This is because the form elements have min and max set to emoty strings for form elements which do not specify a min or max, rather than the former null.
See bug 635499 and bug 635553.  The HTML5 spec adds properties called "min" and "max" on inputs, which always return a string, never null.

Does the web page in question work in other UAs that implement these properties (e.g. recent Chrome)?
Blocks: 635499, 635553
Component: Layout: Form Controls → DOM
(In reply to Boris Zbarsky (:bz) from comment #1)
> See bug 635499 and bug 635553.  The HTML5 spec adds properties called "min"
> and "max" on inputs, which always return a string, never null.
> 
> Does the web page in question work in other UAs that implement these
> properties (e.g. recent Chrome)?

We are actually following the specifications and Chrome 24 and Opera 12.50 have the same behaviour.

John, does your page have the expected behaviour with any recent browser?
I'm afraid this should be resolved as INVALID.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 7 years ago
Resolution: --- → INVALID
Component: DOM → DOM: Core & HTML
Product: Core → Core
You need to log in before you can comment on or make changes to this bug.