This solution is taken from here
class ConfirmPasswordWidget(PasswordWidget): @classmethod def widget(cls, field, value, **attributes): password = PasswordWidget.widget(field, value, **attributes) password.attributes['_class'] += " span5" confirm_id = '%s_confirm' % password.attributes['_id'] confirm = INPUT(**dict(password.attributes, _id=confirm_id, _name=confirm_id, _placeholder='confirm password', _required="required", _oninput="check(this)")) CORE = SCRIPT("""function check(input) { if (input.value != document.getElementById('%(_id)s').value) { input.setCustomValidity('Password Must be Matching.'); } else { // input is valid -- reset the error message input.setCustomValidity(''); } }""" % password.attributes, _language="javascript", _type="text/javascript") return SPAN(DIV(password, confirm, _class="row-fluid"), CORE)
Comments (0)