Roundcube Community Forum

 

Placeholder for login form

Started by xyr123, September 15, 2012, 03:20:00 PM

Previous topic - Next topic

xyr123

Hi,
I'd like to use a placeholder for the login form. Can anyone point me in the right direction?

SKaero


xyr123

Like this:

<td class="input">
<input id="rcmloginuser" type="text" autocapitalize="off" size="40" name="_user" placeholder="Your email">
</td>

SKaero

Probably the simplest way is to make a plugin to include a javascript file and add it that way.

xyr123

oh, I have no experience with js or php, so that would be a bit difficult for me.. Anyone here that would try to make such a plugin?

SKaero

This is just a shot in the dark, completely untested.

Plugin file:

<?php
class placeholder extends rcube_plugin {
    public function 
init() {
        
$this->include_script("placeholder.js");
    }
}


JS file:

$('input[name="_user"]').attr('placeholder', '<username>');
$('input[name="_pass"]').attr('placeholder', '<password>');


Replace the <username> and <password> in the JS file with the placeholders you want.

xyr123

Thanks SKaero.

Just tested the code, but it didn't work

SKaero


xyr123


SKaero

Did you make the placeholder.php and placeholder.js files in a folder named placeholder in the plugins directory and activate the plugin in the main.inc.php?

xyr123

Yes, or I use plugin manager from myroundcube so I activate it from the config in plugin_manager. I can try to activate it from the main.inc.php instead.

xyr123

I just added placeholder to main.inc.php, and it loads the js, but its still not working.

SKaero

Any error messages in the browser js console?

xyr123


SKaero

Try changing the JS file to the following:

$(function() {
  $('input[name="_user"]').attr('placeholder', '<username>');
  $('input[name="_pass"]').attr('placeholder', '<password>');
});