-1

The TextBox with TextMode = "Password" will be empty after assign a value to it's text property.

How can I set predefined password for my password textbox?

Also I want to use this jQuery code for my textbox :

function onclickOfPassword(This) {
    if (This.value == 'Password') {
        This.value = '';
    }
}

function onblurOfPassword(This) {
    if (This.value == '') {
        This.value = 'Password';
    }
}
marc_s
  • 675,133
  • 158
  • 1,253
  • 1,388
SilverLight
  • 17,622
  • 58
  • 171
  • 277
  • i didn't -1, but I did flag as duplicate of- http://stackoverflow.com/questions/4797166/set-default-value-of-a-password-input-so-it-can-be-read – davidsleeps Oct 29 '11 at 10:31

1 Answers1

1

you can do like this....using jquery .....

by using below function we can show and hide two different inputs. You need set one with ID Password and another with ID PasswordDummy, For clients with no javascript, best to set PasswordDummy to display:none initially.

$(‘input’).each(function() 
 {
     if (this.id == ‘Password’) {

       // Handle Password differently – it only gets an onblur, in which it gies invisible and activates the PasswordDummy if it is empty
      // if its blank, make it invisible and Dummy visible

  if (this.value == ”) 
  {
     $(this).hide();
     $(“#PasswordDummy”).show();
   }

  else 
  {
     $(this).show();
     $(“#PasswordDummy”).hide();
  }

$(this).blur(function()
{
   if (this.value == ”) {
   $(this).hide();
   $(“#PasswordDummy”).show();
}
else 
{
    $(this).show();
     $(“#PasswordDummy”).hide();
}
});
}

else if (this.id == ‘PasswordDummy’) {

// Handle Password Dummy differently

this.value = $(this).attr(‘title’);
$(this).addClass(‘text-label’);

$(this).focus(function()
{
  $(this).hide();
  $(“#Password”).show();
  $(“#Password”).focus(); });
}
else if ($(this).attr(‘title’) != undefined)
{
 if (this.value == ”) 
 {
   this.value = $(this).attr(‘title’);
   $(this).addClass(‘text-label’);
  }
$(this).focus(function()
{
   if (this.value == $(this).attr(‘title’)) {
   this.value = ”;
   $(this).removeClass(‘text-label’);
}});

$(this).blur(function() 
{
   if (this.value == ”) {
   this.value = $(this).attr(‘title’);
   $(this).addClass(‘text-label’);
}});
}
});
Enigma State
  • 16,494
  • 25
  • 86
  • 179