--
Ticket URL: <https://code.djangoproject.com/ticket/17637>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_docs: => 1
* needs_tests: => 1
* needs_better_patch: => 1
Old description:
> Having client side javascript validation for forms having common fields
> like username having only alphanumerics or password and Confirm password
> fields matching by providing a validation class.
>
> For example a user should be able to do something like :
>
> forms.TextField(validators ="usernameValidation")
>
> And automatically a javascript validation for this form field should be
> in place.
>
> One way to do it could be using HTML5 attributes like ticket #16304.
New description:
Having client side javascript validation for forms having common fields
like username having only alphanumerics or password and Confirm password
fields matching by providing a validation class.
For example a user should be able to do something like :
{{{
forms.TextField(validators ="usernameValidation")
}}}
And automatically a javascript validation for this form field should be in
place.
One way to do it could be using HTML5 attributes like ticket #16304.
--
Comment:
Per discussion on django-developers, I think we can accept this on
principal (not the patch itself, as it doesn't have tests or docs). IMHO,
best approach would be to use HTML5 features + provide some simple
JavaScript fallback for not widely supported features.
--
Ticket URL: <https://code.djangoproject.com/ticket/17637#comment:1>
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/17637#comment:2>
* owner: nobody => Marcelo Galigniana
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/17637#comment:3>
* needs_better_patch: 1 => 0
* ui_ux: 1 => 0
* needs_tests: 1 => 0
* needs_docs: 1 => 0
Comment:
[https://github.com/django/django/pull/15574 PR] was created.
--
Ticket URL: <https://code.djangoproject.com/ticket/17637#comment:4>
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/17637#comment:5>
* cc: Carlton Gibson (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/17637#comment:6>
Comment (by Marcelo Galigniana):
The HTML5 pattern attribute does a re.fullmatch behind the scenes and our
RegexValidator does a re.search instead.
Should I create a new Validator?
Thanks!
--
Ticket URL: <https://code.djangoproject.com/ticket/17637#comment:7>
* status: assigned => closed
* resolution: => wontfix
Comment:
Hi Marcelo. Thanks for the input on this old-one. Mariusz and I have been
discussing it intermittently… hence the slow follow-up.
In conclusion, I just can't see that the functionality here justifies the
additional passthrough kwarg on the `CharField`.
We can already specify `pattern` via the widget attributes, and a
validator if desired.
I'd much rather we used that API, than add an extra code path for the same
here.
In a project subclassing `CharField` to wrap your own options is likely.
As such I'm going to close this as `wontfix`. In the 10 years since this
was opened things have progressed — as you said on the PR, we don't need
the fallback — I think it was that which may have justified the ticket,
but I don't think ever in that time there's been a stable enough JS option
that we'd have wanted to include... — hence it sitting here I guess.
Even if we're not merging your fix, getting it to a conclusion is a good
step forwards, so thanks! 🎁
I hope that makes sense. C.
--
Ticket URL: <https://code.djangoproject.com/ticket/17637#comment:8>
Comment (by Marcelo Galigniana):
Of course Carlton, totally makes sense! I'm happy to see another old one
closed!
Thanks you for the detailed answer!
🤗
--
Ticket URL: <https://code.djangoproject.com/ticket/17637#comment:9>