I use jQuery so that the inli...">

Shortcut for password field

<input type="text" value="useraname" />
<input type="password" value="password" />

I use jQuery so that the inline labels disappear on click / focus. The password shows the bulls, as usual, but I wonder if it can somehow show the "Password" label as text (and not •••) inside the password field?

Edited to add: I want the user password to be hidden from you!

thanks

+5
source share
7 answers

There are plugins for this. See labelify for example

+6
source

why all this long script for? which is a simple task that can be accomplished with half a line of code:

<input type='text' onclick="this.type='password',value=''" class='watever' value='password'..etc  

greetings

+4
source

. addPassClear("Password") , .

$(function() {
$.fn.addPassClear =
function(text)
{
  return $(this).each(
  function()
  {
    $(this).focus(function(event){$(this).passFocusize(text); $(this).select(); });
    $(this).blur(function(event){$(this).passBlurize(text); });
  });
}
$.fn.passFocusize =
function(text)
{
  return $(this).each(
  function()
  {
    if ($(this).val()==text && $(this).attr("type")=="text")
    {
      $(this).val("");
      this.type="password";
    }
  });
};
$.fn.passBlurize =
function(text)
{
  return $(this).each(
  function()
  {
    if ($(this).val()=="")
    {
      $(this).val(text);
      this.type="text";
    }
  });
};
};
+1

= " ", .

0

, < input type = "text" > .

0

, .

<script language="javascript" type="text/javascript">
    function SwapLabel(id, label, alttype) {
        $(id).focus(function () {
            if (this.value == label) {
                this.value = "";
                if (this.type == 'text' && label == 'Password') {
                    this.type = alttype;
                }
            }
        });
        $(id).blur(function () {
            if (this.value == "") {
                this.value = label;
                if (this.type == alttype && label == 'Password') {
                    this.type = 'text';
                }
            }
        });
    }
    $(document).ready(function () {
        SwapLabel('#UserName', 'Username', '');
        SwapLabel('#Password', 'Password', 'password');
    });
</script>

"label" "title", labelify.js. , , . , :

            if (this.type == 'text' && label == 'Password') {
                this.type = alttype;
            }

            if (this.type == 'text' && label == 'Password') {
                this.type = alttype;
            }

, , , :

, - "" ( •••) ?

0

All Articles