views:

151

answers:

2

I'd like to know how can I add .error class to input elements (to registration app) when the form validation fails.

A: 

This can be done completely through your template.

You build the form template for each form field that you want to test you can use the following example construct

<input type="text" class="reg-txt{% if form.fieldname.errors %} errors{% endif %}"/>

This lets you provide the interface you want without modifying the view & django form code.

wlashell
Is there anything that can be done on the form or widget level? This seems rather verbose, I would want to have this error class on every invalid input field, textarea, select...
Frank Malina
A: 

(Better late than never)

You should be able to do this with Django Uni Form

Gumbah