Materialize datepicker and Flask-WTForms

Viewed 1949

I am using the datepicker from materialize css and have linked it to flask-wtforms.

It works amazingly but I can't get the green validation state on my input when I select a date, it always adds an invalid class as shown, and I can't seem to understand why:

validation problem

The code I am using is below:

form.py

from flask_wtf import Form, FlaskForm
from wtforms import validators, DateField
# from wtforms.fields.html5 import DateField

class ApplicationForm(FlaskForm):
    date_of_birth = DateField('Date of Birth', [validators.Required()], format='%d/%m/%Y')

I am using a macro so the html is rendered:

<div class="input-field col s6">
  <input class="validate datepicker" id="date_of_birth" name="date_of_birth" type="text" value="">
  <label for="date_of_birth">Date of Birth</label>
</div>

The form passes validation when I submit it. I have also tried the html5 DateField but that doesn't seem to work either.

Does anyone know what I am doing wrong?

1 Answers
Related