0

Hi all i am trying to add placeholder to a skin i am building on roundcube. i want it to say username for username and password for password. i know its possible using html but the issue is i dont have acess to the form so i can add placeholder text to the html. I think the only way will be with js or css but as of yet not found a working solution and hoping someone here can help. Here is the form html it has:

    <html>
<input type="hidden" name="_task" value="login"><input type="hidden" name="_action" value="login"><input type="hidden" name="_timezone" id="rcmlogintz" value="_default_"><input type="hidden" name="_url" id="rcmloginurl" value=""><table><tbody><tr><td class="title"><label for="rcmloginuser">Username</label>
</td>
    <td class="input"><input name="_user" id="rcmloginuser" required="required" size="40" autocapitalize="off" autocomplete="off" type="text"></td>
    </tr>
    <tr><td class="title"><label for="rcmloginpwd">Password</label>
    </td>
    <td class="input"><input name="_pass" id="rcmloginpwd" required="required" size="40" autocapitalize="off" autocomplete="off" type="password"></td>
    </tr>
    </tbody>
    </html>

Many thanks all.

Michael Rooks
  • 39
  • 1
  • 2
  • 8

3 Answers3

1

You can use the attribute placeholder and along with setAttribute function, set the desired placeholder.

document.getElementsByName('_user')[0].setAttribute("placeholder", "Username");
document.getElementsByName('_pass')[0].setAttribute("placeholder", "Password");
<html>
<td class="input">
<br><label for="rcmloginuser">Username</label><br>
<input name="_user" id="rcmloginuser" required="required" size="40" autocapitalize="off" autocomplete="off" type="text"></td>
</tr>
<tr><td class="title"><br><label for="rcmloginpwd">Password</label><br>
</td>
<td class="input"><input name="_pass" id="rcmloginpwd" required="required" size="40" autocapitalize="off" autocomplete="off" type="password"></td>
</tr>
</tbody>
</html>

See? now your fields have a placeholder.

Resources

Community
  • 1
  • 1
Ele
  • 33,468
  • 7
  • 37
  • 75
0

In JS, you can select your HTML element and define its placeholder :

document.getElementById("yourId").placeholder = "Placeholder";
sachaandre
  • 21
  • 2
0

A Pure JS Solution would be as below :-

document.getElementById("rcmloginuser").setAttribute("placeholder", "UserName");

You can refer to the following JS Fiddle :-

https://jsfiddle.net/23nigam/q2493u3s/4/

23nigam
  • 601
  • 5
  • 13