-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathform.py
20 lines (17 loc) · 927 Bytes
/
form.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, SubmitField, BooleanField
from wtforms.validators import DataRequired, Length, EqualTo, ValidationError
from model import User
class register_form(FlaskForm):
name = StringField('Name: ', validators=[DataRequired(), Length(min=3,max=25)])
username = StringField('Username: ', validators=[DataRequired(), Length(min=2, max=20)])
submit= SubmitField('Join')
def validate_username(self,username):
user = User.query.filter_by(username=username.data).first()
if user:
raise ValidationError('Username is taken! Please choose another one')
class login_form(FlaskForm):
username= StringField('Username: ',validators=[DataRequired(),Length(min=2,max=20 )])
password= PasswordField('Private Key: ',validators=[DataRequired()])
remember= BooleanField('Remember me')
submit=SubmitField('Enter')