Hello,
You would probably want to make 3 single selects, say day, month, year.
Then make a schema that validates those individually, maybe something like this:
class AgeSchema(Schema):
day = All(Int(not_empty=True), OneOf(days))
month = All(String(not_empty=True), OneOf(months))
year = All(String(not_empty=True), OneOf(years))
chained_validators = [MyAgeValidator(day_field='day',
month_field='month', year_field='year')]
Notice the chained validator, using that you can fully control the
day/month/year validation by just doing it yourself.
You'll have to define your own validator like this:
class MyAgeValidator(FormValidator):
...
And you can pretty much steal all the ideas you need from here, with a
lot of experimenting:
http://formencode.org/formencode/validators.py.html?f=2339&l=2412#2339
Tell me if you need more info, I just felt like I'd be duplicating that.
-ian
On 8/10/07, venomous <[EMAIL PROTECTED]> wrote:
>
> Sorry, maybe i didn't explained well the problem.
> I need to create a signup form where the user *must* indicate his date
> of birth, (i.e like this: http://uk.youtube.com/signup)
> I know that i can create 3 single selectfield: years, month, day and
> put them in a widgetlist, but after this i don't know how i can
> validate the age of the user to see if he has more then 18 years, or
> better, i can only create a validators that check his year of birth
> with the current year, but using this method is not accurate because i
> should check year, month and day with the current date, in order to
> see his correct age.
> So i would create a widgets that has 3 SingleSelectField where i can
> validate the age.
> >From where is hould start?
> Any help is really much appreciated.
>
> On 10 Ago, 18:39, "Jorge Vargas" <[EMAIL PROTECTED]> wrote:
> > On 8/9/07, venomous <[EMAIL PROTECTED]> wrote:
> >
> > > Hello,
> > > how i can create a widget with thedateofbirth?
> > > i would create 3 selectfield like this:
> >
> > >DateofBirth: day | month | year
> >
> > > but form what i can see there is only the option for creating a
> > > singleselectfield
> >
> > make 3 field widgets then wrap it on a widget list, and build your
> > custom widget.
> >
> > > Thanks in advance for any suggestion.
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---