<commit_before>=====
Usage
=====

To use, Ajax Validation requires only that you add a URL(one per form), and some javascript to any page with the form.

Example:

forms.py::
    from django import forms
    
    class ContactForm(forms.Form):
        name = forms.CharField(label='<NAME>')
        email = forms.EmailField(label='Your Email')
        message = forms.CharField(label='Your Message', widget=forms.Textarea)


You would need to add the following url to your urls.py(you need to import the form class)::
    (r'^SOME/URL/$', 'ajax_validation.views.validate', {'form_class': ContactForm}, 'contact_form_validate')

The URL can take any arguments(named, or unamed), and you can also provide a 
callback function, this function is given request, *args, and **kwargs and 
should return a dictionary which is passed to the form constructor.


And then in the template where you want to display the form(in the head)::
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
    {% load jquery_validation %}
    {% include_validation %}
    <script type="text/javascript">
        $(function()    {
            $('#form').validate('{% url contact_form_validate %}', {type: 'ul', fields: ['email'], dom: $('#id_email'), event: 'keyup'});
            $('#form').validate('{% url contact_form_validate %}', {type: 'ul'});
        });
    </script>

As you can see, you need to have jQuery for this to work(here it is being loaded
from google).  In the javascript you use jQuery's selectors to select where the 
form is, and the validate method takes 5 parameters, all optional, first is the 
URL of the validation, here we reverse the URL we set up earlier.  The second 
parameter is a dictionary, it is optional and should either provide type(ul, 
table, or p), this is the type of renderer you used for django's forms(form.as_p, 
etc.), the default is table if nothing is provided.  It can also take a callback 
option which is a function that recieves data, which is the JSON representation 
of any errors, and form, which is the jquery object that you provided.  Finally, 
it takes fields, which is a list of the fields that should be validated, it will 
not display errors that aren't in that list of fields.  The last 2 options are 
dom and event, these allow you to choose when the validation will occur, dom 
should be a jQuery object(i.e.: $('#my_field')), and event should be a jQuery 
event(listed here: http://docs.jquery.com/Events/bind#typedatafn).<commit_msg>whole host of docs fixes<commit_after>=====
Usage
=====

To use, Ajax Validation requires only that you add a URL(one per form), and some javascript to any page with the form.

For example, if you had the following form::
    
    from django import forms
    
    class ContactForm(forms.Form):
        name = forms.CharField(label='<NAME>')
        email = forms.EmailField(label='Your Email')
        message = forms.CharField(label='Your Message', widget=forms.Textarea)


You would need to add the following url to your urls.py(you also need to import the form class)::

    (r'^SOME/URL/$', 'ajax_validation.views.validate', {'form_class': ContactForm}, 'contact_form_validate')


The URL can take any arguments(named, or unamed), and you can also provide a 
callback function, this function is given request, \*args, and \*\*kwargs and 
should return a dictionary which is passed to the form constructor.

And then in the template in which you are displaying the form, you should add::

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
    {% load jquery_validation %}
    {% include_validation %}
    <script type="text/javascript">
        $(function()    {
            $('#form').validate('{% url contact_form_validate %}', {type: 'ul', fields: ['email'], dom: $('#id_email'), event: 'keyup'});
            $('#form').validate('{% url contact_form_validate %}', {type: 'ul'});
        });
    </script>

As you can see, you need to have jQuery for this to work(here it is being loaded
from google).  In the javascript you use jQuery's selectors to select where the 
form is, and the validate method takes 5 parameters, all optional, first is the 
URL of the validation, here we reverse the URL we set up earlier.  The second 
parameter is a dictionary, it is optional and should either provide type(ul, 
table, or p), this is the type of renderer you used for django's forms(form.as_p, 
etc.), the default is table if nothing is provided.  It can also take a callback 
option which is a function that recieves data, which is the JSON representation 
of any errors, and form, which is the jquery object that you provided.  Finally, 
it takes fields, which is a list of the fields that should be validated, it will 
not display errors that aren't in that list of fields.  The last 2 options are 
dom and event, these allow you to choose when the validation will occur, dom 
should be a jQuery object(i.e.: $('#my_field')), and event should be a jQuery 
event(listed `here`_).

.. _here: http://docs.jquery.com/Events/bind#overview
{'fraction_non_alphanumeric': 0.1035895435037066, 'fraction_numerical': 0.0011705033164260631, 'mean_word_length': 3.864326375711575, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2917846', 'n_tokens_mistral': 1440, 'n_tokens_neox': 1377, 'n_words': 664}