# 注册 Forms

```python
# forms.py
class RegisterForm(FlaskForm):
    school_id = IntegerField("学号", validators=[DataRequired(message="请输入数据")])
    username = StringField("username", validators=[DataRequired(message="请输入数据")])
    password = PasswordField("password", validators=[DataRequired(message="请输入数据")])
    repeat_password = PasswordField('repeat', validators=[EqualTo(password, message="两次输入的密码不一致")])
    submit = SubmitField("submit")


# /blueprints/auth.py
@auth_bp.route('/register', methods=['GET', 'POST'])
def register():
    form = RegisterForm()
    if form.validate_on_submit():
        school_id = form.school_id.data
        username = form.username.data
        return 'success'
    return render_template('register.html', form=form)



# tempates/register.html

<form action="{{ url_for("auth.register") }}" method="post">
            {{ form.csrf_token }}
            <img src="http://via.placeholder.com/100x100/aaa/fff?text=IMG" alt="" class="center-block register-img">
            <div class="input-group">
                <span class="input-group-addon"><span class="glyphicon glyphicon-equalizer"></span></span>
                {{ form.school_id.label(class="sr-only") }}
                {{ form.school_id(class="form-control", placeholder="学号") }}
            </div>
            <div class="input-group">
                <span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
                {{ form.username.label(class="sr-only") }}
                {{ form.username(class="form-control", placeholder="用户名") }}
            </div>
            <div class="input-group">
                <span class="input-group-addon"><span class="glyphicon glyphicon-asterisk"></span></span>
                {{ form.password.label(class="sr-only") }}
                {{ form.password(class="form-control", placeholder="密码") }}
            </div>
            <div class="input-group">
                <span class="input-group-addon"><span class="glyphicon glyphicon-asterisk"></span></span>
                {{ form.repeat_password.label(class="sr-only") }}
                {{ form.repeat_password(class="form-control", placeholder="重复密码") }}
            </div>
            {{ form.submit(class="btn btn-primary input-sm col-sm-12") }}
        </form>
```
