View the Project on GitHub on-site/guards.js

Guards Type


signature: jQuery.guards.version

available since: 1.0.0

This version of guards.js library as a string, like "1.0.0".



available since: 1.0.0

Name a guard. This behaves the same way as $.guard(selector), except it uses the parameter to define a named guard with the given name, instead of defining a new guard affecting the given selector. Any attributes applied to it will be passed on to any guards that utilize this named guard. A named guard may be utilized by passing the name on to the using method.

Anything except 'test'



available since: 1.0.0

Insert a style element to the document head that will style guard errors and invalid fields. This will default to styling .invalid-field with a background color of #ffff66 and .error-message with a color of #ff0000 and a left margin of 10px.

There are 2 optional arguments for this method. The first is an optional css scope to restrict the styling affects with. The second is an object expected to contain a field and/or message property with css styles desired for that aspect of the styling. The field property will add styling for invalid fields while the message property will add styling for error messages. The properties of these objects may contain any key that is a valid css attribute, with an appropriate value.