Вы можете сделать это следующим образом .... используя jquery .....
, используя функцию ниже, мы можем показать и скрыть два разных ввода.Вам нужно установить один с идентификатором Password, а другой с идентификатором 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’);
}});
}
});