Opened 18 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 , 18 years ago
comment:2 by , 18 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
comment:3 by , 18 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 , 17 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Like anonymous said, it isn't really useful.
Also it wouldn't hurt to automatically set size="#" in the HTML since it's easy to override.