Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#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)

0001-Fixed-20630-Removed-maxlength-attribute-from-NumberI.patch (4.1 KB ) - added by Simon Charette 11 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 by Simon Charette, 11 years ago

Component: UncategorizedForms
Keywords: html5 added
Triage Stage: UnreviewedAccepted
Type: UncategorizedBug
Version: 1.6-alpha-1master

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?

comment:2 by Simon Charette, 11 years ago

Has patch: set

Added a patch for review, the only possibly missing part is the release note.

comment:3 by Baptiste Mispelon, 11 years ago

Triage Stage: AcceptedReady 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 Simon Charette, 11 years ago

Great, I'll commit this. I thought we shipped this feature in 1.5, thanks for looking this up!

comment:5 by Simon Charette <charette.s@…>, 11 years ago

Resolution: fixed
Status: newclosed

In 04628e2016641bfa657333d6ee1f5b371c17f62c:

Fixed #20630 -- Removed maxlength attribute from NumberInput.

This attribute is only allowed on inputs of type "text", "search", "url",
"tel", "email", or "password".

Thanks to yoyoma for the report and @bmispelon for the review.

comment:6 by Michael Angeletti, 11 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.

Note: See TracTickets for help on using tickets.
Back to Top