2011-10-29 8 views
-1

TextMode = "Password"のTextBoxは、テキストプロパティに値を割り当てた後で空になります。TextMode = "Password"のときasp.net TextBoxで*****を事前に定義して表示

パスワードテキストボックスにあらかじめ定義されたパスワードを設定するにはどうすればよいですか?

また、私は私のテキストボックスのために、このjQueryのコードを使用したい:

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

function onblurOfPassword(This) { 
    if (This.value == '') { 
     This.value = 'Password'; 
    } 
} 
+0

私は-1ませんでしたが、私は重複としてフラグをしたオブhttp://stackoverflow.com/questions/4797166/set-default-value-of-a-password-input-so-it -can-be-read – davidsleeps

答えて

1

あなたはjqueryのを使用して....このように行うことができます.....

機能の下に使用することによって、我々は見ることができます2つの異なる入力を非表示にします。 IDパスワードを持つものとIDを持つ別のものを設定する必要があります。PasswordDummy、JavaScriptを使用しないクライアントの場合は、PasswordDummyを最初に表示するように設定します。

$(‘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’); 
}}); 
} 
}); 
+0

あなたのコードをインデントするといいでしょう:) – Kev

関連する問題