-
Notifications
You must be signed in to change notification settings - Fork 2
/
forms.py
39 lines (36 loc) · 906 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from flask_wtf import Form
from wtforms import StringField, PasswordField
from wtforms.validators import DataRequired, Regexp, Email, EqualTo, Length, ValidationError
def name_exists(form, field):
import createuserdb
a = c.execute("SELECT users FROM users WHERE users='{}'".format(field.data))
if len(a) == 0:
return ValidationError('Username exists')
class RegisterForm(Form):
username = StringField(
'username',
validators=[
DataRequired(),
Regexp(
r'^[a-zA-Z0-9_]+$',
message=('Username should be one word, letters,'
'numbers, and underscores only.')
)
])
email = StringField(
'email',
validators=[
DataRequired(),
Email()])
password = PasswordField(
'password',
validators=[
DataRequired(),
Length(min=2),
EqualTo('password2',message="Password don't match")
])
password2 = PasswordField(
'Confirm Password',
validators=[
DataRequired()
])