我有一些字符串字段,我想避免使用任何空格。在Flask-wtforms中如何做到这一点?
class RegistrationForm(FlaskForm):
first_name = StringField('First name',validators=[DataRequired(),Length(min=2,max=64)])
last_name = StringField('Last name',validators=[DataRequired(),Length(min=2,max=64)])
尝试Regexp:
validators.Regexp('^\w+$', message="Username must contain only letters numbers or underscore"),
http://wtforms.simplecodes.com/docs/0.6.1/validators.html#wtforms.validators.Regexp