By default, the password fieldbox masked all the text the user typed as ** .
I want to be able to display a string on the Password field box.
So it should says "Please enter your Password" initially when the password control is loaded.
Currently aspx showing it as * ** * ***
How can i best achieve this?
Cheers
Use TextMode.
<asp:TextBox ID="Password" runat="server" TextMode="Please enter your Password"
onclick="this.value=''; this.type='password'; ">Password
</asp:TextBox>
or
Use placeholder.
For EX:
<input type="password" placeholder="Please enter your Password">
You can achieve it using jquery:
HTML:
<input id="password" value="password" class="password-input" />
JS:
$('.password-input').bind('click', function() {
if ($(this).val() === "Please enter your Password")
{
this.type = "password";
$(this).val('');
}
});
$('.password-input').bind('blur', function() {
if ($(this).val() === "")
{
this.type = "text";
$(this).val('Please enter your Password');
}
});
JSFIDDLE:
You can also see previous SO questions about the same thing:
Set default value of a password input so it can be read
Set Default Value Of A Password Input / A Scenario / Issue in IE 8
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.