Equalto validator doesnt work

hi all,

my code below doesnt work ie the new password and confirm new password, the user on the web when they click the submit button they dont get the message saying passwords dont match and i have no idea why

the length validator works fine, ive imported the modules

from wtforms.validators import InputRequired, Length, DataRequired, EqualTo, Regexp
new_password = PasswordField('New_Password', validators=[InputRequired(), Length(min=12), EqualTo('confirm_new_password', message='Passwords must match')])
    confirm_new_password = PasswordField('Confirm_New_Password')

thanks,
rob

Do these PasswordFields belong to the same class, and is that class a Form, like shown in the documentation?

it does i think, sorry i say i think as im new to python

from flask import Flask, render_template, request
from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, BooleanField, DecimalField, RadioField, SelectField, TextAreaField, FileField, validators, SubmitField
from wtforms.validators import InputRequired, Length, DataRequired, EqualTo, Regexp, ValidationError

app = Flask(__name__)
app.config['SECRET_KEY'] = 'secretkey'


class MyForm(FlaskForm):
    username = StringField('Username', [ validators.InputRequired('Required')])
    old_password = PasswordField('Old_Password', [ validators.InputRequired('Required')])
    password = PasswordField('New_Password', [ validators.InputRequired('Required'), validators.EqualTo('confirm', message='Passwords must match'), validators.Length(min=12)])
    confirm = PasswordField('Confirm_New_Password')
    domain = SelectField('domain', choices=[('prod', 'prod'), ('corp', 'corp')])
    submit = SubmitField('Submit')
    
@app.route('/', methods=['GET', 'POST'])
def index():
    form = MyForm()
    if form.validate_on_submit():
        username = form.username.data
        old_password = form.old_password.data
        password = form.password.data
        confirm = form.confirm.data
        domain = form.domain.data
        submit = form.submit.data
    return render_template('index.html', form=form)

if __name__ == '__main__':
    app.run()