diff --git a/jquery.placeholder.js b/jquery.placeholder.js index 99d5ca1..2fb8109 100644 --- a/jquery.placeholder.js +++ b/jquery.placeholder.js @@ -21,10 +21,11 @@ }; }; // Submit handler on all forms containing input[placeholder] - $('form:has([placeholder])').click(function() { + // Needs to be via .click() + $('form:has([placeholder]) input[type=submit]').click(function() { // if ($(this).has('.placeholder') never returns false here — WTF? - if ($(this).find('.placeholder').length) { - $(this).find('.placeholder:first').val('').focus().removeClass('placeholder'); + if ($(this.form).find('.placeholder').length) { + $(this.form).find('.placeholder:first').val('').focus().removeClass('placeholder'); return false; }; }); diff --git a/jquery.placeholder.min.js b/jquery.placeholder.min.js index e55ffa5..05fc2f3 100644 --- a/jquery.placeholder.min.js +++ b/jquery.placeholder.min.js @@ -3,4 +3,4 @@ * @link http://github.com/mathiasbynens/Placeholder-jQuery-Plugin * @author Mathias Bynens */ -(function(a){a.fn.placeholder=function(){if(this[0]&&'placeholder' in document.createElement('input')){return this}function b(c){if(c.val()===''||c.val()===c.attr('placeholder')){c.addClass('placeholder').val(c.attr('placeholder'))}else{c.removeClass('placeholder')}}a('form:has([placeholder])').click(function(){if(a(this).find('.placeholder').length){a(this).find('.placeholder:first').val('').focus().removeClass('placeholder');return !1}});return a(this).each(function(){var c=a(this);if(c.is(':password')||!c.is(':input')){return}b(c);c.focusin(function(){if(c.val()===c.attr('placeholder')){c.val('').removeClass('placeholder')}}).focusout(function(){b(c)})})}})(jQuery); \ No newline at end of file +(function(a){a.fn.placeholder=function(){if(this[0]&&'placeholder' in document.createElement('input')){return this}function b(c){if(c.val()===''||c.val()===c.attr('placeholder')){c.addClass('placeholder').val(c.attr('placeholder'))}else{c.removeClass('placeholder')}}a('form:has([placeholder]) input[type=submit]').click(function(){if(a(this.form).find('.placeholder').length){a(this.form).find('.placeholder:first').val('').focus().removeClass('placeholder');return !1}});return a(this).each(function(){var c=a(this);if(c.is(':password')||!c.is(':input')){return}b(c);c.focusin(function(){if(c.val()===c.attr('placeholder')){c.val('').removeClass('placeholder')}}).focusout(function(){b(c)})})}})(jQuery); \ No newline at end of file