• 4970 views
  • 0 comments
  • loading...

How to validate input fileds

Validators are classes used to validate input fields (including forms generated from database tables). With the advanced forms derived from SQLFORM, validators create widgets such as drop-down menus and lookups from other tables.  Here is an example of using a validator with a FORM:







## Input form field usage

INPUT(_name='a', requires=IS_INT_IN_RANGE(0, 10))

## Validator for a table field
db.define_table('person', Field('name'))
db.person.name.requires = IS_NOT_EMPTY()

loading...

Sources / Reference

" Web2py Book"


Comments

loading...

Powered by
Web2py

Hosted on
www.pythonanywhere.com
(affiliated link)