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]>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]> 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;
>>>                }
>>>        });
>>> });
>>>
>>
>

Reply via email to