The tasty morsel of the day is a simple jQuery plugin. It makes suggestions to the user for how to strengthen a weak password. For the purposes of this example, strong passwords contain characters in all of four categories: capital letters, lower case letters, numerals, and punctuation characters.
Reusable behavior is implemented as a jQuery plugin. Adding behavior with jQuery is a snap. But one-off jQuery snippets can be made more maintainable and reusable by rewriting them as plugins.
Behavior can be applied to multiple elements on a page. An easy mistake to make in your jQuery plugin work is to assume that only one element per page will be affected by a particular behavior. If all you’re doing is altering the element itself then this may work just fine. In this example, however, we’re adding password suggestions in a
<span> next to the password input box. Each of multiple input boxes with this behavior should have its own suggestions
<span>. Note the use of each and how we create a corresponding
<span> for each input box receiving the behavior.