diff options
| author | Jon Dufresne <jon.dufresne@gmail.com> | 2016-03-28 11:02:04 -0700 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-04-21 19:16:38 -0400 |
| commit | ec6121693f112ae33b653b4364e812722d2eb567 (patch) | |
| tree | b791f1345a114d07657a3d226d1c5ff4b1e3f369 /docs/topics/forms | |
| parent | 4d1c229ee5cb210e8b592a8d9c87d4a66864328e (diff) | |
Fixed #22383 -- Added support for HTML5 required attribute on required form fields.
Diffstat (limited to 'docs/topics/forms')
| -rw-r--r-- | docs/topics/forms/formsets.txt | 5 | ||||
| -rw-r--r-- | docs/topics/forms/index.txt | 8 |
2 files changed, 9 insertions, 4 deletions
diff --git a/docs/topics/forms/formsets.txt b/docs/topics/forms/formsets.txt index 8aa3f67b2a..6a0a43b7c1 100644 --- a/docs/topics/forms/formsets.txt +++ b/docs/topics/forms/formsets.txt @@ -164,6 +164,11 @@ As we can see, ``formset.errors`` is a list whose entries correspond to the forms in the formset. Validation was performed for each of the two forms, and the expected error message appears for the second item. +Just like when using a normal ``Form``, each form in the formset may include +HTML attributes such as ``maxlength`` for browser validation. However, forms of +formsets won't include the ``required`` attribute as that validation may be +incorrect when adding and deleting forms. + .. method:: BaseFormSet.total_error_count() To check how many errors there are in the formset, we can use the diff --git a/docs/topics/forms/index.txt b/docs/topics/forms/index.txt index 487f8dd64e..86de7d1b06 100644 --- a/docs/topics/forms/index.txt +++ b/docs/topics/forms/index.txt @@ -259,7 +259,7 @@ The whole form, when rendered for the first time, will look like: .. code-block:: html+django <label for="your_name">Your name: </label> - <input id="your_name" type="text" name="your_name" maxlength="100"> + <input id="your_name" type="text" name="your_name" maxlength="100" required /> Note that it **does not** include the ``<form>`` tags, or a submit button. We'll have to provide those ourselves in the template. @@ -512,11 +512,11 @@ Here's the output of ``{{ form.as_p }}`` for our ``ContactForm`` instance: .. code-block:: html+django <p><label for="id_subject">Subject:</label> - <input id="id_subject" type="text" name="subject" maxlength="100" /></p> + <input id="id_subject" type="text" name="subject" maxlength="100" required /></p> <p><label for="id_message">Message:</label> - <textarea name="message" id="id_message"></textarea></p> + <textarea name="message" id="id_message" required></textarea></p> <p><label for="id_sender">Sender:</label> - <input type="email" name="sender" id="id_sender" /></p> + <input type="email" name="sender" id="id_sender" required /></p> <p><label for="id_cc_myself">Cc myself:</label> <input type="checkbox" name="cc_myself" id="id_cc_myself" /></p> |
