#20630 closed Bug (fixed)
HTML5 validation broken by maxlength attributes in number inputs
| Reported by: | Michael Angeletti | Owned by: | nobody |
|---|---|---|---|
| Component: | Forms | Version: | dev |
| Severity: | Normal | Keywords: | html5 |
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
The commit for #19686 adds maxlength to number inputs with max digits (https://code.djangoproject.com/attachment/ticket/19686/ticket-19686-claudep-github-revised.diff#L85)
Paste the following into http://validator.w3.org/#validate_by_input and submit:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<div>
<input type="number" maxlength="5">
</div>
</body>
</html>
One of the messages you'll notice is: maxlength when type is text, search, url, tel, e-mail, or password.
So, it appears that HTML5 doesn't allow a maxlength attribute for number inputs.
Attachments (1)
Change History (7)
comment:1 by , 12 years ago
| Component: | Uncategorized → Forms |
|---|---|
| Keywords: | html5 added |
| Triage Stage: | Unreviewed → Accepted |
| Type: | Uncategorized → Bug |
| Version: | 1.6-alpha-1 → master |
by , 12 years ago
| Attachment: | 0001-Fixed-20630-Removed-maxlength-attribute-from-NumberI.patch added |
|---|
comment:2 by , 12 years ago
| Has patch: | set |
|---|
Added a patch for review, the only possibly missing part is the release note.
comment:3 by , 12 years ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
The patch looks good.
7ec2a21be15af5b2c7513482c3bcfdd1e12782ed was committed after the 1.5 release and already includes a release note.
The note makes no mention of maxlength specifically, so I think we're good.
comment:4 by , 12 years ago
Great, I'll commit this. I thought we shipped this feature in 1.5, thanks for looking this up!
comment:5 by , 12 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
comment:6 by , 12 years ago
Thanks bmispelon and charettes. I'm sorry I didn't make it back in time to offer codereview support. You guys are friggin quick.
Agreed that we should remove this attribute on number input, I guess we overlooked this :/
I'll write a patch removing this feature and making sure tests don't fail. Should we add a release note concerning this change?