On 3 February 2012 22:03, Adrian Holovaty <adr...@holovaty.com> wrote: > On Fri, Feb 3, 2012 at 11:46 AM, Karthik Abinav > <karthikabin...@gmail.com> wrote: >> I was thinking about a feature that could be implemented. For common >> fields like username having only alphanumeric , or phone numbers having only >> numbers, a client side validation need not be written every time.Instead one >> could directly write something like, >> >> forms.CharField(validator = "usernamevalidation") >> >> in the forms definition and the client side validation for that field would >> automatically be taken care of by the validator class. This will save a lot >> of time while making large websites with lot of registration forms and in >> general be helpful to people who dont really know javascript and yet want >> some amount of frontend validation in place. > > I like the idea of having a JavaScript version of form validation. > Basically we could make a view class that takes a Form object in > __init__() and returns JSON of the errors in a consistent way -- this > would be very easy to do. Then we could provide some standard > JavaScript to parse that JSON and add the error messages to the > appropriate fields in the form in a consistent way.
I don't get it. That would require sending the data to the server (right?), so it's not really client-side. I think http://www.dajaxproject.com/ does exactly that. What I would like to see instead is providing HTML5 attributes for standard fields and making it easier to add ones to custom ones. Some simple to implement ones are: "required", min/max for number fields, max_length for a textarea. Regular expression can be supported via "pattern" (with some code to translate them to JS regexp syntax). -- Łukasz Rekucki -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.