Example: I have 2 <input> on a html page, which is a form (assume it is login form, with username and password, both are required and will do validation on this.).
The behavior of is_valid I see is:
When submit, the returned errors for the form are:
This field is required (for username)
This field is required (for password)
We'll usually render these messages for the fields (example: {{ form }} will automatically do all these).
Now, my question is, it seems like is_valid will trigger validation on both username and password every time? How to stop it in case one field cannot pass the validation? Does it make sense to validate all these always? I think in some of web pages, the behaviour we see is, when one field does not fulfill the requirements, it give an error message for this only, and when user submit again but the next field does not fulfill the requirement, it give error for this field.
Current behaviour in django:
user name: .....(input box)
password: ....(input box)
Submit without any value, we get:
user name: .....(input box) This field is required
password: ....(input box) This field is required
I expect:
user name: .....(input box) This field is required
password: ....(input box) (No error here)
If username is entered and password is empty, submit again, we'll get:
user name: what you enter here (input box)
password: ....(input box) This field is required
Any idea how to achieve this?
Thanks,
Shenghong