See here for custom validators:
http://web2py.com/book/default/chapter/07#Custom-Validators
and here for custom widgets:
http://web2py.com/book/default/chapter/07#Widgets
If your widget returns an INPUT helper, you can assign your custom validator
to the 'requires' argument of INPUT to make it the default for the widget.
However, the book recommends instead associating the validator to the
database field, and then assign requires=field.requires in the widget
definition.
Anthony
On Tuesday, June 28, 2011 3:46:28 PM UTC-4, David J wrote:
> Thanks.
>
> Isn't IS_MATCH a validator?
>
> I wanted a widget that had this built in;
>
> How would I build a custom form widget that has this validator as its
> default.
>
> On 6/28/11 3:32 PM, Niphlod wrote:
> > you need to play with regexes.....
> >
> > assuming "parenthesis-3 digits-parenthesis-space-3 digits-hypen-4
> > digits" sequence
> >
> > requires = IS_MATCH('\([\d]{3}\) [\d]{3}-[\d]{4}',
> > error_message='please enter phone number in format (800)
> > 555-1212')
> >
> > should do it.
> >
> > On Jun 23, 9:50 pm, "David J."<[email protected]> wrote:
> >> I need help trying to create a custom widget;
> >>
> >> I want to create a phone-number widget
> >>
> >> I want it to only accept text in (800) 555-1212
> >>
> >> I am not sure how to do this.
> >>
> >> Any ideas would be greatly appreciated.
>
>