Validation is always performed server side.

if you use FORM(....INPUT(....)....) that each input gets its own
requires=[..]

if you use SQLFORM(table) than the requires are from the
table.field.requires.

Anyway, do not use FORM(...INPUT(....)...) but use
SQLFORM.factory(...Field(...)...) It is more powerful.

On Aug 29, 4:45 pm, leftcase <christopherrow...@gmail.com> wrote:
> Hi group, first time post!
>
> A question about server side form validation.
>
> I have been following the tutorials on the web2py website and I'm
> building a simple form like this in the controller:
>
> form=FORM(TABLE(TR("Username:",INPUT(_type="text",_name="username",requires 
> =[IS_NOT_EMPTY(),
> IS_NOT_IN_DB(db, 'users.username')])),
>
> TR("Email:",INPUT(_type="text",_name="email",requires=IS_EMAIL())),
>          TR("",INPUT(_type="submit",_value="New User"))))
>
> When I do this, is web2py doing the form validation server side, or is
> it using client side javascript methods to validate the users' input?
> I wouldn't want the end user to turn off javascript in the browser to
> bypass validation.
>
> I notice in the model I can also define my requirements like this:
>
> db.users.username.requires=[IS_NOT_EMPTY(), IS_NOT_IN_DB(db,
> 'users.username')]
>
> What's the difference between the two ways of defining form
> validation?
>
> Thanks in advance! :-)
>
> Chris

Reply via email to