Answer the question
In order to leave comments, you need to log in
How to translate wtforms tooltips?
How to translate tooltips that pop up when the input format is incorrect in the form?
from flask.ext.wtf import Form
from wtforms import TextField
from wtforms.validators import Required
from wtforms import validators
from wtforms.fields.html5 import EmailField
class RegisterForm(Form):
Nickname = TextField('Nickname', validators = [Required()])
Email = EmailField('Email address', [validators.DataRequired(), validators.Email()])
Password = TextField('Password', validators = [Required()])
RePassword = TextField('Password', validators = [Required()])
Answer the question
In order to leave comments, you need to log in
These are browser tooltips, depending on the specific system. They appear when validation attributes (required, pattern ...) are set on the fields. If you want to change - do not specify attributes, check it yourself and draw tooltips the way you want.
Certainly not babel, but a solution. And the validation crashes on html5 validation. Which is not yet available in all browsers.
REQ_TEXT = u'Заполните это поле'
class RegistrationForm(Form):
Nickname = TextField('Nickname', validators = [Required(REQ_TEXT)])
Password = TextField('Password', validators = [Required(u'Укажите пароль')])
email = StringField(u'Электронная почта',
validators=[Required(REQ_TEXT),
Length(1, 64),
Email(REQ_TEXT)])
def validate_email(self, field):
if User.query.filter_by(email=field.data).first():
raise ValidationError(u'Почта уже занята')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question