Hi, you can create a custom validator for doing that
include this in any model:
### THE CUSTOM VALIDATOR ###
class IS_EMAIL_LIST(object):
def __init__(self, error_message='Email %s is invalid', sep=","):
self.format = format
self.error_message = error_message
self.sep = sep
def __call__(self, value):
emails = value.split(self.sep)
for email in emails:
if IS_EMAIL()(email)[1] != None:
return (email, error_message % email)
return (emails, None)
### THE TABLE ###
db.define_table('emails',
Field('list','text', requires=IS_EMAIL_LIST())
)
#####################
NOTE: IS_EMAIL_LIST(sep=";") to change list separator
[]'s
On Wed, Jul 6, 2011 at 3:51 AM, Luis Goncalves <[email protected]> wrote:
> Hello!!!
>
> I have a form where an organizer can input a list of comma-separated email
> address, so that each person receives an invitation to register on the
> website (you can only register for the site if you have an invitation).
>
> Is there an easy way to get the "if form.accepts()" to use
> "requires=IS_EMAIL()"
> when the form element is not just a single email address, but a list of
> comma-separated email addresses?
>
> Thanks!
> Luis.
>
--
--
Bruno Rocha
[ About me: http://zerp.ly/rochacbruno ]
[ Aprenda a programar: http://CursoDePython.com.br ]
[ O seu aliado nos cuidados com os animais: http://AnimalSystem.com.br ]
[ Consultoria em desenvolvimento web: http://www.blouweb.com ]