Opened 17 years ago

Closed 17 years ago

#4020 closed (wontfix)

USPhoneField, USZipCodeField and USSocialSecurityNumberField should implement HTML maxlength

Reported by: joe4444 Owned by: nobody
Component: Forms Version: dev
Severity: Keywords: usphonefield uszipcodefield ussocialsecuritynumberfield
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

For a CharField with max_length=30 it is not necessary to set attrs={'maxlength': '30'} in that form's widget (or set a widget at all in many cases). However, the fields USPhoneField, USZipCodeField and USSocialSecurityNumberField do not set maxlength="#" in the HTML they produce. In fact, USZipCodeField explicitly sets max_length=None. Maybe there is a good reason for this, but it seems like these fields could automatically add maxlength="#" to their output considering they validate for a specific length and format.


    phone = forms.USPhoneField(widget=forms.TextInput(attrs={'maxlength': '12'}))    # a bit verbose
    phone = forms.USPhoneField()    # should be equivalent to the previous line


I wish I had a patch for this, but I wouldn't know where to begin.

Change History (4)

comment:1 by joe4444, 17 years ago

Also it wouldn't hurt to automatically set size="#" in the HTML since it's easy to override.

comment:2 by Simon G. <dev@…>, 17 years ago

Triage Stage: UnreviewedDesign decision needed

comment:3 by anonymous, 17 years ago

maxlength is a pain when you're copy/pasting your info from a file, with dashes or spaces, and the form expects spaceless entry. Then you get an incomplete paste, further wasting the user's time.

comment:4 by Julian Bez, 17 years ago

Resolution: wontfix
Status: newclosed

Like anonymous said, it isn't really useful.

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