On Apr 1, 5:04 pm, carlo <syseng...@gmail.com> wrote:
> sorry for this "out of sync" answer but though I managed some "tricks"
> to tackle the (problem of) validation in pure html forms during these
> years, I would be curious about an answer to Mengu's request of
> "showing how to make validation with manual forms".

When I need to do this, I do it with making a memory-based table, and
SQLFORM or SQLFORM.factory, and do whatever validation I need.

>
> Sorry DenesL but you did not answer the question as you supposed a
> model in place, so I would really appreciate a simple html form which
> preserves validation. Thank you

There is a fundamental "fuzziness" around this:   If you have manual
forms without data persistence, what are you validating?  (and what
can you not do by building up a simpel memory-db model, and validating
transient data against that?)

Second - if it is _really_ transient data that you are validation,
then even memory db, per request, could get pretty "heavy" in terms of
server load - why not do client-side validation?

Either way, this begs the question:   why exactly this form of
question?

I want to know the reasons / situation / logic behind this specific
(server-side, no data persistence, no temporary, memory model of the
data)  request.

As it stands, it seems to me to be missing some key information /
motivations.

Yarko
>
> carlo
>
> On 15 Mar, 21:09, DenesL <denes1...@yahoo.ca> wrote:
>
> > On Mar 15, 6:28 am, Mengu <whalb...@gmail.com> wrote:
>
> > > > First of all, I am not sure what is the problem you are trying to
> > > > solve. Even if you havecustomformsand you build all the form html
> > > > manually you can still use the existing validation mechanism.
>
> > > I don't want to use crud or sqlform or any html helper. i build my
> > >formsmanually. and actually if you show me how to make validation
> > > with manualforms, it would be good.
>
> > You could set the error messages in the requires
>
> > db.users.name.requires = IS_NOT_EMPTY(error_message = "Please enter
> > your name")
> > db.users.email.requires = [
> >   IS_EMAIL(error_message="Given e-mail is not a valid one."),
> >   IS_NOT_IN_DB(db,'users.email',error_message="Sorry, this e-mail
> > already exists in our database")
> > ]
>
> > create your form with the same field names and to check them do
>
> > for n,v in request.vars.items():
> >   rr=db.users[n].requires
> >   if isinstance(rr,list):
> >     t,e=v,None
> >     for r in rr:
> >       t,e=r(t)
> >       if e: break
> >   else:
> >     t,e=rr(v)
> >   if e:
> >     form.errors[n]=e
>
> > # here do whatever you need to do with form.errors
>
> > Denes

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.

Reply via email to