Code

Opened 2 years ago

Last modified 2 years 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 lrekucki)

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 2 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 2 years ago by karthikabinav

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

comment:1 Changed 2 years ago by lrekucki

  • 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 fallback for not widely supported features.

comment:2 Changed 2 years ago by lrekucki

  • Triage Stage changed from Unreviewed to Accepted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as new
The owner will be changed from nobody to anonymous. Next status will be 'assigned'
as The resolution will be set. Next status will be 'closed'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.