Skip to content

Commit

Permalink
Allow the user to enter values that are equal to the placeholder value.
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiasbynens committed Jan 19, 2011
1 parent d36d006 commit ce625cd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
13 changes: 9 additions & 4 deletions jquery.placeholder.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* HTML5 Placeholder jQuery Plugin v1.7
* HTML5 Placeholder jQuery Plugin v1.8
* @link http://github.com/mathiasbynens/Placeholder-jQuery-Plugin
* @author Mathias Bynens <http://mathiasbynens.be/>
*/
Expand Down Expand Up @@ -45,8 +45,10 @@

function setPlaceholder(elem) {
var $replacement,
$input = $(this);
if ($input.val() === '' || $input.val() === $input.attr('placeholder')) {
$input = $(this),
$origInput = $input,
isInitialized = $input.data('placeholder-init');
if ($input.val() === '' || (!isInitialized && $input.val() === $input.attr('placeholder'))) {
if ($input.is(':password')) {
if (!$input.data('placeholder-textinput')) {
try {
Expand All @@ -68,6 +70,9 @@
} else {
$input.removeClass('placeholder');
}
if (!isInitialized) {
$origInput.data('placeholder-init', true);
}
}

$(function() {
Expand All @@ -86,4 +91,4 @@
$('.placeholder').val('');
});

})(jQuery);
}(jQuery));
4 changes: 2 additions & 2 deletions jquery.placeholder.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ce625cd

Please sign in to comment.