The plugins site is currently in development.
We've been looking to provide a higher-quality, spam-free experience at the plugins site for some time, and a major error on our part forced us to shut down the current site before we could put the new one in place. We are developing a new site, and you can follow along with its development on GitHub. For more information about this transition, including steps you can take as a plugin author to prepare, please read our post about what's going on.
Watermark plugin for jQuery
Updates included in version 3.0.6:
- Added multiple "sanity checks" throughout the code for potential unknown attribute values. This is in response to some reports of the plugin not functioning alongside some third party code and other rare situations. For example, should gracefully handle a situation when third party code unexpectedly modifies a DOM element containing a watermark. Naturally, there are limits to how much you can protect a developer from third party code interference.
- Removed .end() from fn.watermark() return value, which was making chaining impossible.
- Immediately returns from fn.watermark() call if no elements are in the jQuery set - "best practice".
Updates included in version 3.0.5:
- Changed licensing to match jQuery's: Dual-licensed under MIT or GPL2.
- Fixed bug that affected ASP.NET validation controls under rare circumstances.
Updates included in version 3.0.4:
- Fixed a compatibility issue with jQuery 1.4, which no longer appears to support the ":search" selector.
Updates included in version 3.0.3:
- Solved Issue #9 (Form doesn't submit in Chrome when submitting programmatically) - This issue only manifested itself when native watermark support was turned off in Google Chrome, and the form was submitted programmatically [by calling form.submit()]. It happened because Google Chrome (and Google Chrome alone) makes the native form.submit function invisible to JavaScript, making the ability to hijack the seemingly non-existent function very difficult. A creative solution was achieved (see the code if you're interested).
- Solved Issue #11 (ASP.NET ValidationGroup bug) - The issue occured because the original arguments were not being passed to the hijacked function (the ASP.NET client validation function).
- Fixed a potential, but unreported, issue that could arise if arguments (for some reason) were passed to the form.submit function.
Updates included in version 3.0.2:
- Solved Issue #7 (Resolving conflict with ASP.NET validators) - Added capability to hijack any number of JavaScript functions that, when called, first hide all watermarks and then call the originally-intended function. Initially, only the Page_ClientValidate is specified to be overridden. Others will be added if feedback dictates. If a function specified is not found on the page, the function name is ignored on that page.
- Solved Issue #8 (Error when there's no form on the page: this.form is null) - Added a test to ensure there is a form on the page before attempting to override the form submit function.
- The $.watermark.version property will properly return "3.0.2". The version number was not updated in the 3.0.1 release, and continued to report as 3.0.
- Added detection for the presence of watermark activity on a page so that hideAll() will not bother trying to do anything if there are no watermarks to hide. Also, calling hideAll() multiple times in succession will process the elements on the page only once.
- Switched from YUI Compressor to Microsoft Ajax Minifier for minification. The new Microsoft minifier produces more compact code than YUI, so even with the additional code, the overall size is not much bigger than the last release.
Updates included in version 3.0.1:
- Solved Issue #5 (postback issue with ASP.NET DropDownList) - Fixed form submit bug with IE6 and IE7 that threw a JavaScript error when a form was submitted programmatically.
- Minor cosmetic change suggested on jQuery issues list (Text blink when setting specific class). Reversed two lines so that class name is set before the watermark text is set.
Updates included in version 3.0:
- The plugin gets another major version number boost due to significant improvements in areas not covered by any other watermark plugin for jQuery. Several new features and bug fixes, including everything on the Issue list that could be verified. (Issue list: http://code.google.com/p/jquery-watermark/issues/list)
- Solved Issue #1 - Integrate with WebKit browsers that support input tags with type="search". (Issue list refers to Safari alone, but it turns out that Google Chrome also supports type="search" elements.)
- Solved Issue #4 - Dragging and dropping text now replaces the watermark. This was the most significant change, and required several work-arounds due to a variety of browser glitches.
- Added support for native browser watermarks in WebKit browsers ("placeholder" attribute). New "useNative" option in the plugin allows native browser watermark support to be enabled/disabled globally, or for individual watermarks. When a watermark is created, the plugin detects if native browser support is available, and automatically uses it, as long as useNative is true. Two good reasons to turn *off* native support is the lack of CSS class name support (native watermark/placeholder is always light gray), and native watermarks/placeholders in type="search" elements do not always work properly with drag-and-drop. (Using the watermark plugin support (useNative:false) for type="search" elements *does* work properly with drag-and-drop.) However, for typical non-styled watermark usage, native browser support is encouraged, by leaving useNative set to true. (Default is true).
- New "$.watermark.options" object stores the default options for watermarks. There are currently two properties of $.watermark.options: className and useNative. (BREAKING CHANGE: $.watermark.className has been eliminated, and replaced with $.watermark.options.className.) The use of an object to store default options is is keeping with current jQuery techniques, and allows for future expansion in a much more flexible manner.
- New watermark calling signature - $( selector ).watermark( [text] , [options] );
- Example: $("#myElement").watermark("Enter Username", {className: "inputspace", useNative: false});
- Plugin continues to support the use of a string value for the second argument, for backward compatibility. If a string value is passed for the second argument, it is used as the className for the watermark, overriding the default value in $.watermark.options.className.
- "useNative" option can be either a boolean or a function. If useNative is a function, then the function is evaluated for each element in the matched set, returning a boolean value specifying if native support is enabled for the element. The function is passed one argument -- a jQuery object containing the element being tested as the only element in its matched set -- and the DOM element being tested is the object on which the function is invoked (the value of "this").
- Worked around jQuery/Chrome bug that would execute $(...).filter(...).each( fn ) twice for each element in the matched set. (Fairly confident this is a jQuery bug of some type.)
- Fixed Chrome bug where password watermarks longer than 10 characters would cause the functionality to fail.
- Added $.watermark.version (string value). Currently set to "3.0".
- Changed naming convention of files, removing the version number from the file name and folder name. In real-world usage, it can be disruptive to try to implement a new version of the plugin if the file name includes the version number. There are some who feel differently about this issue, and prefer the version number in the file name, but I prefer it removed. It is easy to add back into the file name, if desired by the individual developer.
This plugin is designed for jQuery 1.2.3 and greater.
Downloads
Development
(11 votes)
