Click here to Skip to main content
15,906,455 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Hi In asp.net , I have used
ASP.NET
<asp:TextBox Text="NPassword" TextMode="Password" ID="TextPassword" runat="server" Height="22px" Width="253px">

and I want to make value as Password , and when user clicks on password field, the value should be blank for user to enter password

i.e. focus and blur

how to do this

regards
Posted
Updated 26-Nov-13 23:22pm
v3
Comments
Thanks7872 27-Nov-13 4:46am    
make value as Password ? Means what?
maulikshah1990 27-Nov-13 4:48am    
can u give example for asp.net textbox with password

Hi Shah,

I think you are asking about watermark[^] in the textbox.
If am right then I suggest you to refer link[^],link2[^],link3[^] and link4[^]

Hope this helps you a bit.

Regards,
RK
 
Share this answer
 
Check out below link:-

http://jsfiddle.net/w4Hh4/3/[^]


Or use placeholder
<asp:TextBox ID="txtId" runat="server"   TextMode="Password" Placeholder="Password"  > </asp:TextBox>


Or
<input type="password" onfocus="if(this.value=='Password') {this.value='';}" onblur="if(this.value=='') {this.value='Password'}" value="Password"  />
 
Share this answer
 
Hi,
try this.
JavaScript
<script>
function ChangeToPassField() 
{
    if (document.getElementById('<%= txtPassword.ClientID %>').type != "password") 
    {
        document.getElementById('<%= txtPassword.ClientID %>').type = "Password";
        document.getElementById('<%= txtPassword.ClientID %>').value = "";
    }
}
function ChangeToNormal() 
{
    if (document.getElementById('<%= txtPassword.ClientID %>').value == "") 
    {
        document.getElementById('<%= txtPassword.ClientID %>').type = "SingleLine";
        document.getElementById('<%= txtPassword.ClientID %>').value = "Password"
    }
}
</script>

ASP
<asp:textbox text="NPassword" textmode="Password" id="txtPassword" onfocus="ChangeToPassField()" onblur="ChangeToNormal()" runat="server" height="22px" width="253px" xmlns:asp="#unknown"></asp:textbox>

Hope it helps you.
Thanks.
 
Share this answer
 
Suppose this the html...


<input type="text" class="MemberId" />
<input type="password" class="Password" />
<input type="button" class="btnLogin" value="Login" />


******Add latest Jquery library here************

$(function () {
$('.memberLoginForm .MemberId').val('Member Id');
$('.memberLoginForm .Password').val('Password');

$('.memberLoginForm .MemberId').focus(function () {
if ($(this).val() == 'Member Id') {
$(this).val('');
}
});

$('.memberLoginForm .MemberId').blur(function () {
if ($(this).val() == '') {
$(this).val('Member Id');
}
});
$('.memberLoginForm .Password').focus(function () {
if ($(this).val() == 'Password') {
$(this).val('');
}
});
$('.memberLoginForm .Password').blur(function () {
if ($(this).val() == '') {
$(this).val('Password');
}
});
});

This will solve your problem..
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900