C# 当TextMode=”时,在asp.net文本框中显示预定义的*****”;密码";
为文本属性赋值后,带有TextMode=“Password”的文本框将为空 如何设置密码文本框的预定义密码 此外,我还想将此jQuery代码用于我的文本框:C# 当TextMode=”时,在asp.net文本框中显示预定义的*****”;密码";,c#,asp.net,textbox,passwords,C#,Asp.net,Textbox,Passwords,为文本属性赋值后,带有TextMode=“Password”的文本框将为空 如何设置密码文本框的预定义密码 此外,我还想将此jQuery代码用于我的文本框: function onclickOfPassword(This) { if (This.value == 'Password') { This.value = ''; } } function onblurOfPassword(This) { if (This.value == '') {
function onclickOfPassword(This) {
if (This.value == 'Password') {
This.value = '';
}
}
function onblurOfPassword(This) {
if (This.value == '') {
This.value = 'Password';
}
}
您可以这样做……使用jquery 通过使用下面的函数,我们可以显示和隐藏两个不同的输入。您需要将一个设置为ID Password,另一个设置为ID PasswordDummy,对于没有javascript的客户端,最好将PasswordDummy设置为最初显示:none
$(‘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’);
}});
}
});
我没有-1,但我标记为的副本-