I am working on the Flask tutorial from Miguel for input validation with WTForms. The forms.py is defined below:
from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, BooleanField, SubmitField
from wtforms.validators import InputRequired
class LoginForm(FlaskForm):
username = StringField('Username',validators=[InputRequired()])
password = PasswordField('Password',validators=[InputRequired()])
remember_me = BooleanField('Remember Me')
submit = SubmitField('Sign In')
HTML file as below:
{% extends "base.html" %}
{% block content %}
<h1>Sign In</h1>
<form action="" method="post">
{{ form.hidden_tag() }}
<p>
{{ form.username.label }}<br>
{{ form.username(size=32) }}<br>
{% for error in form.username.process_errors %}
<span style="color:red;">[{{error}}]</span>
{% endfor %}
</p>
<p>
{{ form.password.label }}<br>
{{ form.password(size=32) }}
{% for error in form.password.process_errors %}
<span style="color:red;">[{{error}}]</span>
{% endfor %}
</p>
<p>{{ form.remember_me() }} {{ form.remember_me.label }}</p>
<p>{{ form.submit() }}</p>
</form>
{% endblock %}
What I tried to achieve is to have the form report missing username and password input with error messages in red color. However, I got the following result when I click "submit"
I couldn't find where in the WTForms package produce the error message "Please fill out this field". I also checked the result HTML page, there is no Javascript code generated for this.
I have tried in both Opera and Edge and got the same error message. Is that something from Windows?
Thanks in advance for your help