-
Notifications
You must be signed in to change notification settings - Fork 0
/
forms.py
25 lines (18 loc) · 1015 Bytes
/
forms.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from flask_wtf import FlaskForm
from wtforms import StringField, TextAreaField, SubmitField, validators, ValidationError
# validators.required: prior to post request being sent,
# - the program will show an error message saying that the field needs to
# have been filled in.
#
# validators.email: will send the post request, but the validation must
# be handled seperately.
# TextArea: multiline input
_prompt = "Please enter your "
class ContactForm(FlaskForm):
name = StringField("Name",
validators=[validators.required(_prompt + "name")])
email = StringField("Email", validators=[validators.required(_prompt + " email address."),
validators.email(_prompt + " email address.")])
subject = StringField("Subject", validators=[validators.required("Please enter a subject.")])
message = TextAreaField("Message", validators=[validators.required("Please enter a message.")])
submit = SubmitField("Send")