The errors for an individual field are inserted just after the field:

>>> from web import form
>>> f = form.Form(form.Textbox('username', form.regexp("^[A-Za-z0-9]*$", 
'Username must contain only letters and numbers')
>>> f1 = f()
>>> f1.validates(username='b123') 
True
>>> f1.valid
True
>>> f1.render()
u'<table>\n    <tr><th><label 
for="username">username</label></th><td><input type="text" id="username" 
value="b123" name="username"/></td></tr>\n</table>'
>>> f2 = f()
>>> f2.validates(username='b_123')
False
>>> f2.valid
False
>>> f2.render()
u'<table>\n    <tr><th><label 
for="username">username</label></th><td><input type="text" id="username" 
value="b_123" name="username"/><strong class="wrong">Username must contain 
only letters and numbers</strong></td></tr>\n</table>'

I am wondering if you want your username field to always contain at least 
one letter or number?  If so, you should change the '*' to a '+'.

-Jim
On Thursday, October 3, 2013 6:37:46 PM UTC-5, pip wrote:
>
> I'm facing an issue, not a big one mind you - the regexp/validator error 
> is not shown.
>
> Lets say for example:
>
> form.Textbox("username", form.regexp("^[A-Za-z0-9]*$", 'Username must 
> contain only letters and numbers')
>
> That does work, but the error is never shown.
>
> In the template:
>
>       $if not form.valid:
>         <p class="error">
>           Try again!
>         </p>
>
> Is there a specific way to access these errors? Due to lack of 
> documentation I assumed it would be magic - its not a big problem not 
> having the specific error given to a user and I can even come up with my 
> own way to get around it but it would be nice to use the built in errors. 
> Or are they simply internal?
>
> Thanks.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/webpy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to