Skip to content

Informs about number of filled input elements and allows quick clearing

License

Notifications You must be signed in to change notification settings

Moonbird-IT/js.FieldObserver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

js-field-observer

Informs about number of filled input elements and allows quick clearing. The plugin currently supports observation on textboxes, password fields, selects, radio buttons and check boxes.

Project url: https://github.com/Moonbird-IT/js-field-observer

Author: Sascha Meyer

Feel free to fork, use, change and distribute this plugin. If you extend or optimise the plugin, please let me know and I'll update the git repository with your changes.

Open issues:

  • The plugin uses jQuery but right now it's not a jQuery plugin (on the road map)
  • If one field is observed by more than one observer, clearing the field using one observer's clear functionality will not inform the other observer.

Usage:

1.) Add the JS and CSS references 2.) Set up a new observer:

var fieldObserver = new FieldObserver({
    observed: ['#txt-box', '#select-single', '#radio-box'], // observed fields (mandatory)
    infoField: '#observer-info', // status field refernce, defaults to '#observer-info'
    infoText: 'filter(s) set' // string appended to number of filled fields, defaults to 'fields filled'
});

3.) If you need to add fields dynamically to the observer, use:

fieldObserver.addField('#txt-box2');

Example:

See the following jsFiddle for an example:

http://jsfiddle.net/Moonbird_IT/2Na5Y/

About

Informs about number of filled input elements and allows quick clearing

Resources

License

Stars

Watchers

Forks

Packages

No packages published