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". > > 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
Mengu's initial post uses a model and I believe I offered sample code to validate a form in his example. The form can be built any way you want, it does not matter. Now if you narrow down the question don't expect the answer to still apply. Besides web2py is after all a database driven framework. And if you say you don't like using any of the included tools to work with forms then I don't know what you are really after. > 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.