Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#28480 closed Bug (invalid)

Nonstandard "minlength" property to <input/>

Reported by: Tomáš Pecina Owned by: nobody
Component: Forms Version: 1.11
Severity: Normal Keywords: minlength input form field
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

CharField with a "minlength" argument generates "minlength" property, which is (rightly) complained of by some HTML validators. As W3C does not recognize this property as legitimate (and the question is if they ever will), I belive it should not be generated. If anyone needs it, s/he can always add it in the attrs dictionary, or subclass CharField.

Change History (7)

comment:1 by Tim Graham, 7 years ago

Component: HTTP handlingForms
Resolution: invalid
Status: newclosed
Type: UncategorizedBug

My research didn't confirm that the minlength attribute is invalid.
https://www.w3.org/TR/html5/forms.html#the-maxlength-and-minlength-attributes
http://caniuse.com/#feat=input-minlength
Perhaps you can cite your source if you believe otherwise.

comment:2 by Tomáš Pecina, 7 years ago

Sure; https://www.w3schools.com/tags/tag_input.asp and, which is even more relevant, please try this:

echo '<input minlength=3>' | tidy

I'm using libtidy to check all HTML during unit testing on my project (https://github.com/tompecina/legal), and I had to drop minlength because the output did not pass the test.

In my opinion, it is a matter of good policy not to include any nonstandard or proprietary HTML markup; it will have no impact on the validation as the MinLengthValidator is automatically added.

comment:3 by Claude Paroz, 7 years ago

https://validator.w3.org/nu/ does not complain. The latest draft of HTML 5.2 on http://w3c.github.io/html/single-page.html does include the minlength attribute. I confirm this ticket's resolution. You may try opening a ticket in tidy bugtracker instead.

comment:4 by Tomáš Pecina, 7 years ago

That's a good point, Claude. HOWEVER, we should realize that minlength is not the same thing as maxlength, conceptually, and browser developers are right in not implementing the former very eagerly. With maxlength, there is a clear and evident visual and possibly acoustic feedback: when the limit is reached, the user's keypresses are not displayed, and perhaps, a warning beep is produced. On the other hand, there is no such aid with minlength. Therefore, it might be wiser to let the Django validator do the job, and inform the user by a message such as "Currency code must consist of exactly three characters." By hardcoding the minlength property (which is not that easy to remove), we may be doing a disservice to the application developer. Please, give the issue a second thought.

comment:5 by Claude Paroz, 7 years ago

Tomáš, I'd suggest that you explain your issue on the django-developer mailing list.

comment:6 by Tomáš Pecina, 7 years ago

No, why? I simply think it's not a good idea to use automatically every property simply because it is there, and caution is needed because certain checks are better performed on the server (or by JavaScript) than in the browser. You think otherwise, and you are the boss here, so I supressed the property manually in my code and this is the end of the story for me. Thanks for your time, anyway!

in reply to:  6 comment:7 by Claude Paroz, 7 years ago

Replying to Tomáš Pecina:

You think otherwise, and you are the boss here

That's why I suggested the mailing list, so the decision could be discussed by more people than just one or two "bosses".

so I supressed the property manually in my code and this is the end of the story for me. Thanks for your time, anyway!

If you found a solution working for you, that's great.

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