python - WTForms doesn't validate MAC address -
i'm using wtforms' macaddress
validator, doesn't recognize valid mac addresses enter. why isn't working?
{'choice': [u'invalid mac address.']}
class editform(form): choice = textfield('choice', validators=[datarequired(), macaddress()]) @app.route('/', methods=['get', 'post']) def devicechoice(): form = editform() if form.validate_on_submit(): print form.choice.data return redirect(url_for('editdevice')) else: print form.errors return render_template('devicechoice.html', form=form)
<form action="" method="post"> {{ form.hidden_tag() }} {{ form.choice() }} <input type="submit"> </form>
question has been answered @ketouem, putting ":" after every 2 characters of mac address validates form. (12:34:56:78:ab:cd)
Comments
Post a Comment