Some of the information here may be outdated, please check the book instead
[edit]

IS_LENGTH validator has now two arguments instead of one. Now it is possible to set minimal length of the field:

INPUT(_type='text', _name='name', requires=IS_LENGTH(maxsize=255,
                                                     minsize=0))
  1. maxsize: maximum allowed length / size
  2. minsize: minimum allowed length / size

Examples:

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))
© 2008-2010 by Massimo Di Pierro - All rights reserved - Powered by web2py - design derived from a theme by the earlybird
The content of this book is released under the Artistic License 2.0 - Modified content cannot be reproduced.