Perform JS validation of the login form.

This reduces roundtrips hopefully and will provide a friendlier error
message than what would otherwise be produced by Django.

(imported from commit 034aeef00043e3bf059583770f6c08c4f73ceeb5)
This commit is contained in:
Luke Faraone 2013-07-05 21:38:37 -04:00
parent c646d95b7a
commit e5031e5a0f
2 changed files with 14 additions and 3 deletions

View File

@ -2,6 +2,13 @@
{# Login page. #}
{% load compressed %}
{% block customhead %}
{{ block.super }}
{% compressed_js 'signup' %}
{% endblock %}
{% block portico_content %}
<script type="text/javascript">
@ -30,19 +37,19 @@ autofocus('#id_username');
<div class="row">
<div class="span5 login-area">
<form name="login_form" method="post" class="form-horizontal"
<form name="login_form" id="login_form" method="post" class="form-horizontal"
action="{% url 'django.contrib.auth.views.login' %}?next={{ request.get_full_path }}">
{% csrf_token %}
<div class="control-group">
<label for="id_username" class="control-label">Email</label>
<div class="controls">
<input id="id_username" type="text" name="username" value="{{ email }}" maxlength="72" />
<input id="id_username" type="text" name="username" class="email required" value="{{ email }}" maxlength="72" />
</div>
</div>
<div class="control-group">
<label for="id_password" class="control-label">Password</label>
<div class="controls">
{{ form.password }}
<input id="id_password" name="password" class="required" type="password">
</div>
</div>
<div class="control-group">

View File

@ -47,4 +47,8 @@ $(function () {
$('#errors').empty();
}
});
$("#login_form").validate({
errorClass: "text-error"
});
});