I am using Django's modelform and its really good. How can I highlight the actual text box (e.g. border:red ) if there is a validation error associated with it. Basically what i want is to add a class (error) if there is a validation error to a field.
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Django __str__ returned non-string (type NoneType)
- Evil ctypes hack in python
What about defining error_css_class? http://docs.djangoproject.com/en/dev/ref/forms/api/#styling-required-or-erroneous-form-rows?
template :
Try this?
To answer the original question.
You can add the desired class to the field in the view to where you are submitting your form and doing your
form.is_valid()
check. Not the prettiest but it will work.Expanding upon errx's answer.
Add the CSS
to specifically highlight the field