Opened 5 years ago

Last modified 17 months ago

#17637 new New feature

Client side validation classes for forms

Reported by: karthikabinav Owned by: nobody
Component: Forms Version: 1.3
Severity: Normal Keywords: Forms, Client Side validation, js
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: yes
Needs tests: yes Patch needs improvement: yes
Easy pickings: no UI/UX: yes

Description (last modified by Łukasz Rekucki)

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.

Attachments (1)

pattern_charfield.patch (1.4 KB) - added by karthikabinav 5 years ago.
Supply accepted characters as a regular expression in CharField forms. Uses HTML5 attribute 'pattern' to provide the client side validation.

Download all attachments as: .zip

Change History (3)

Changed 5 years ago by karthikabinav

Attachment: pattern_charfield.patch added

Supply accepted characters as a regular expression in CharField forms. Uses HTML5 attribute 'pattern' to provide the client side validation.

comment:1 Changed 5 years ago by Łukasz Rekucki

Description: modified (diff)
Needs documentation: set
Needs tests: set
Patch needs improvement: set

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 fall back for not widely supported features.

Last edited 17 months ago by johnhomes (previous) (diff)

comment:2 Changed 5 years ago by Łukasz Rekucki

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