requires=IS_EMPTY_OR([IS_LENGTH(maxsize=200),
IS_MATCH('^[a-zA-Z0-9\s\#\.\$\-\_]+$',
error_message='Character
Not Allowed.')])
Anthony
On Tuesday, September 17, 2013 2:44:14 PM UTC-4, REM wrote:
>
> I have a form field which is not required, but when it is submitted with
> data, I want the data to be validated. The problem is, I get the validator
> triggering when the form is submitted with no value in that field. I want
> it to wait until there's data in there to validate it and ignore it if
> blank. I thought I could get this behavior with required=False and then
> using requires= validators, but it is failing the validation every time
> when there's no data in the field. How do you get it to validate data
> that's present and ignore blanks?
>
> The field in question is in the db.py as follows:
>
> Field('special_code1', 'string', length=200, required=False,
> label='Special
> Code 1',
> requires=[IS_LENGTH(maxsize=200),
> IS_MATCH('^[a-zA-Z0-9\s\#\.\$\-\_]+$',
> error_message='Character
> Not Allowed.')]
> ),
>
>
>
> There are no other controllers acting on this data, and no combination of
> anything I try above gets me what I want.
>
>
>
>
>
>
--
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.