Hi Abhishek
I first tried this:
form.element(_id='center_manager_email')['_placeholder']='Enter Email'
and the i also tried your solution:
{{register_form.element('input#auth_user_username')['_placeholder'] =
'Username'}}
But in both cases i get the error - <type 'exceptions.TypeError'>
'NoneType' object does not support item assignment
What exactly are the lines to add placeholder in web2py login forms. Please
suggest
On Saturday, 17 December 2011 13:43:06 UTC+5:30, Abhishek Gupta wrote:
>
> Sorry, I got the error. Correct thing to be done was :
>
> {{register_form.element('input#auth_user_username')['_placeholder'] =
> 'Username'}}
>
> On 17 December 2011 12:48, Abhishek Gupta <[email protected]
> <javascript:>> wrote:
>
>> Thanks, it worked.
>>
>> But surprisingly
>> form.element('input.username')['_placeholder'] = 'Username'
>>
>> doesn't work and instead gives the error
>>
>> Traceback (most recent call last):
>>
>>
>> File "/home/www-data/web2py/gluon/restricted.py", line 194, in restricted
>>
>>
>> exec ccode in environment
>>
>>
>> File "/home/www-data/web2py/applications/chat/views/default/login.html",
>> line 109, in <module>
>>
>> TypeError: 'NoneType' object does not support item assignment
>>
>>
>> On 17 December 2011 12:04, Anthony <[email protected] <javascript:>>
>> wrote:
>>
>>> Assuming the standard user() function:
>>>
>>> form = auth()
>>> if request.args(0) == 'login':
>>> form.element('input.password')['_placeholder'] = 'Password'
>>>
>>> Not sure placeholders will show in plain text in all browsers -- may
>>> need a JS workaround for that (change the field type dynamically to text on
>>> blur).
>>>
>>> Anthony
>>>
>>>
>>> On Saturday, December 17, 2011 1:20:21 AM UTC-5, Abhishek Gupta wrote:
>>>>
>>>> Hello
>>>>
>>>> I am customizing web2py login form, but appear to stuck with this one.
>>>>
>>>> In a normal HTML5 form, for password I can do following:
>>>> <input type="password" name="cpassword"
>>>> id="cpassword" placeholder="Re-password" />
>>>>
>>>> But how can i add a similar placeholder field to the web2py login form
>>>> for the password field. I was able to do the same for the username field
>>>> using the following function :
>>>>
>>>> $('#auth_user_username').each(function() {
>>>>
>>>> var default_value = "Username";
>>>> $(this).focus(function(){
>>>> if(this.value == default_value) {
>>>> this.value = '';
>>>> }
>>>> });
>>>>
>>>> $(this).blur(function(){
>>>> if(this.value == '') {
>>>> this.value = default_value;
>>>> }
>>>> });
>>>> });
>>>>
>>>
>>
>
--
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/d/optout.