How to display error messages from form with ajax using python django
<p>I'm trying to display the error messages that I provided on my forms, but it only display the id name instead of error message.</p>

<p>Here's my code</p>

<p><b>Form.py</b></p>

<pre><code>class SecurityCode(forms.Form):
    sCode = forms.RegexField(regex=r'^\w+$', widget=forms.TextInput(attrs=dict(id="scode", name="scode", required=True, size=25, placeholder="    Security Code")), error_messages={ 'invalid': "This value must contain only letters, numbers and underscores." })
</code></pre>

<p><b>Views.py</b></p>

<pre><code>def security(request):
    if request.method == 'POST':
            securityField = SecurityCode(request.POST)

            if taxpayerField.is_valid():
                return HttpResponse("success")
            else:
                return HttpResponse(taxpayerField.errors)
</code></pre>

<p>Note: I'm trying to get the error message in this views not on my html because I'm trying to alert that on my javascript. Also this is just my sample code not the original one.</p>