• 2570 views
  • 0 comments
  • loading...

Checks if length of field's value fits between given boundaries

Checks if length of field's value fits between given boundaries. Works for both text and file inputs.

For all field types except for files, it checks the length of the value. In the case of files, the value is a cookie.FieldStorage, so it validates the length of the data in the file, which is the behaviour one might intuitively expect.








# Check if text string is shorter than 33 characters:

INPUT(_type='text', _name='name', requires=IS_LENGTH(32))

# Check if password string is longer than 5 characters:
INPUT(_type='password', _name='name', requires=IS_LENGTH(minsize=6))

# Check if uploaded file has size between 1KB and 1MB:
INPUT(_type='file', _name='name', requires=IS_LENGTH(1048576, 1024))

Attributes / Arguments

Tthe maximum allowed length / size

# Check if text string is longer than 33 characters:
INPUT(_type='text', _name='name', requires=IS_LENGTH(maxsize=32))

The minimum allowed length / size

# Check if password string is longer than 5 characters:
INPUT(_type='password', _name='name', requires=IS_LENGTH(minsize=6))


loading...


Comments

loading...

Powered by
Web2py

Hosted on
www.pythonanywhere.com
(affiliated link)