Enforce minlen on "password" fields in HTML5 capable browsers.

pull/7/head
Ferry Boender 10 years ago
parent 200fea8598
commit fb63870487
  1. 6
      src/formrender.py
  2. 9
      src/webapp.py

@ -45,7 +45,7 @@ class FormRender(object):
u'class="{classes}" style="{style}" />',
"file": u'<input {required} type="file" name="{name}" '
u'class="{classes}" style="{style}" />',
"password": u'<input {required} type="password" min="{minval}" '
"password": u'<input {required} type="password" minlength="{minlen}" '
u'name="{name}" value="{value}" class="{classes}" '
u'style="{style}" />',
"text": u'<textarea {required} name="{name}" rows="{rows}" '
@ -164,7 +164,7 @@ class FormRender(object):
return tpl.format(name=name, required=required, classes=classes,
style=style)
def r_field_password(self, name, value, minval=None, required=False,
def r_field_password(self, name, value, minlen=None, required=False,
classes=None, style=""):
"""
Render a password field to HTML.
@ -172,7 +172,7 @@ class FormRender(object):
if classes is None:
classes = []
tpl = self.field_tpl['password']
return tpl.format(name=name, value=value, minval=minval,
return tpl.format(name=name, value=value, minlen=minlen,
required=required, classes=classes, style=style)
def r_field_text(self, name, value, rows=4, cols=80, required=False,

@ -371,6 +371,7 @@ class ScriptFormWebApp(WebAppHandler):
params["style"] = field.get("style", "")
# Get field-specific parameters
if field['type'] not in ('file', 'checkbox'):
params['value'] = form_values.get(field['name'], '')
@ -379,13 +380,15 @@ class ScriptFormWebApp(WebAppHandler):
if field['type'] == 'string':
params['size'] = field.get('size', '')
if field['type'] in ('string', 'password'):
params['minlen'] = field.get('minlen', '')
params['maxlen'] = field.get('maxlen', '')
if field['type'] in ('number', 'integer', 'float', 'password'):
params['minval'] = field.get("min", '')
if field['type'] in ('string'):
params['maxlen'] = field.get('maxlen', '')
if field['type'] in ('number', 'integer', 'float'):
params['minval'] = field.get("min", '')
params['maxval'] = field.get("max", '')
if field['type'] == 'text':

Loading…
Cancel
Save