Hello, I'm trying to validate a list:string field with is_alphanumeric and is_length - trying to ensure that names are no longer than 6 alphanumeric characters in length. (I'm running web2py 2.8.1 in ubuntu 12.04)
view: <li>Sample name *: {{=form.custom.widget.sample_name}}</li> controller: form = SQLFORM(db.register,fields=[..,'sample_name',...]) if form.validate(onvalidation=validate_sample_name): form.vars.id = db.register.insert(**dict(form.vars)) response.flash = 'Reg saved.' redirect(URL('samples', 'default', 'index')) elif form.errors: response.flash = 'form has errors' return dict(form=form) model: db.define_table( "register", ..... Field('sample_name','list:string'), ) def validate_sample_name(form): for sample in form.vars.sample_name: out,ers = IS_ALPHANUMERIC()(sample) and IS_LENGTH(maxsize=6)('sample') if ers: form.errors.sample_name = ers The above does check for alphanumeric characters but doesn't seem to check for the length of each sample name. Am I doing something wrong? Many thanks. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.