diff --git a/jquery.placeholder.js b/jquery.placeholder.js
index dad08c9..a2c2602 100644
--- a/jquery.placeholder.js
+++ b/jquery.placeholder.js
@@ -1,5 +1,5 @@
/*!
- * HTML5 Placeholder jQuery Plugin
+ * HTML5 Placeholder jQuery Plugin v1.0
* @link http://github.com/mathiasbynens/Placeholder-jQuery-Plugin
* @author Mathias Bynens
*/
@@ -20,17 +20,17 @@
$elem.removeClass('placeholder');
};
};
- // Submit handler on all forms containing input[placeholder]
- // Needs to be via .click()
- $('form:has([placeholder]) :submit').click(function() {
- // if ($(this).has('.placeholder') never returns false here — WTF?
- if ($(this.form).find('.placeholder').length) {
- $(this.form).find('.placeholder:first').val('').focus().removeClass('placeholder');
- return false;
- };
+ // This selector could be shortened to form:has([placeholder]) but that would be less efficient
+ $('form:has(input[placeholder])').submit(function() {
+ // Clear the placeholder values so they don’t get submitted
+ $('.placeholder', this).val('');
+ });
+ // Clear placeholder values upon page reload
+ $(window).unload(function() {
+ $('.placeholder').val('');
});
// Yes, .each() — in case .placeholder() is called on several elements, which is very likely, e.g. $('input').placeholder();
- return $(this).each(function() {
+ return this.each(function() {
var $input = $(this);
// Quit if the current element is a password input, or not an input at all
if ($input.is(':password') || !$input.is(':input')) {
diff --git a/jquery.placeholder.min.js b/jquery.placeholder.min.js
index b5e51da..a0de164 100644
--- a/jquery.placeholder.min.js
+++ b/jquery.placeholder.min.js
@@ -1,6 +1,6 @@
/*!
- * HTML5 Placeholder jQuery Plugin
+ * HTML5 Placeholder jQuery Plugin v1.0
* @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]) :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
+(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(input[placeholder])').submit(function(){a('.placeholder',this).val('')});a(window).unload(function(){a('.placeholder').val('')});return 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