Hello,

I need to validate a form only if X or more checkboxes were checked and I 
cannot find out how. Bellow is the simple code which needs the validator 
(there are 5 checkboxes - same name - and the form should validate only if 
3 or more were selected). Can you please point me to the right direction?

import web
from web import form

render = web.template.render('templates/')

urls = ('/', 'index')
app = web.application(urls, globals())

args = ()
for i in range(0, 5):
    args = args + ( form.Checkbox('check', value=str(i) ), )
             
args = args + (form.Button("submit", type="submit", description="Submit"),)

register_form = form.Form(*args)

class index:
    def GET(self):
        # do $:f.render() in the template
        f = register_form()
        return render.register(f)

    def POST(self):
        f = register_form()
        if not f.validates():
            return render.register(f)
        else:
            pdata=web.input(check=[])
            print pdata
            
if __name__=="__main__":
    web.internalerror = web.debugerror
    app.run()

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/webpy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to