Is there any way to check if the format of an input in Django comments is correct? Specifically, I want to check that the email entered has the form @thisuniversity.edu? I want to make sure that all the comments come from people in the university, so this would be a way to check this.
I overwrote the code for the comments/form.html file to include specific functionality.
The specific file is below:
{% load comments i18n %}
<form action="{% comment_form_target %}" method="post">{% csrf_token %}
{% if next %}<div><input type="hidden" name="next" value="{{ next }}" /></div>{% endif %}
{% for field in form %}
{% if field.is_hidden %}
<div>{{ field }}</div>
{% else %}
{% if field.errors %}{{ field.errors }}{% endif %}
<p
{% if field.errors %} class="error"{% endif %}
{% ifequal field.name "honeypot" %} style="display:none;"{% endifequal %}>
{% if field.name != "url" and field.name != "email" and field.name != "name" %}
{{ field.label_tag }} {{ field }}
{% elif field.name = "email" %}
<b>Enter your university email address.</b><br><br>
{{ field.label_tag }} {{ field }}
{% elif field.name = "name" %}
{{ field.label_tag }} {{ field }}
{% endif %}
</p>
{% endif %}
{% endfor %}
<p class="submit">
<input type="submit" name="post" class="submit-post" value="{% trans "Post" %}" />
</p>
</form>
Thanks.