from flask_wtf import FlaskForm from wtforms import StringField, PasswordField from wtforms.validators import InputRequired, Length, Regexp class LoginForm(FlaskForm): username = StringField('Username', validators=[ InputRequired(message='Username is required.'), Regexp(r'^[a-zA-Z][a-zA-Z0-9_]{0,19}$', message='Invalid username format.') ]) password = PasswordField('Password', validators=[ InputRequired(message='Password is required.'), Length(min=1, max=30, message='Password must be between 1 and 30 characters long.') ])