https://github.com/kinduff/limitcheckbox
jQuery plugin that offers an easy way to setup a limit to a checkbox collection.
https://github.com/kinduff/limitcheckbox
Last synced: about 1 year ago
JSON representation
jQuery plugin that offers an easy way to setup a limit to a checkbox collection.
- Host: GitHub
- URL: https://github.com/kinduff/limitcheckbox
- Owner: kinduff
- Created: 2014-04-28T17:08:13.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2014-06-06T17:11:30.000Z (about 12 years ago)
- Last Synced: 2025-05-29T00:58:10.908Z (about 1 year ago)
- Language: JavaScript
- Size: 188 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
limitcheckbox.js
===========
## Welcome
This is a jQuery plugin that offers an easy way to setup a limit to a checkbox collection. If you have 5 checkboxes and you want to limit the selection to 3 and leave the other ones disabled, this plugin is going to work for you.
## Gem Install
Add this line to your application's Gemfile:
```bash
gem 'limitcheckbox'
```
And then execute:
```bash
$ bundle
```
Or install it yourself as:
```bash
$ gem install limitcheckbox
```
Then include **limitcheckbox.js** in your javascript file
```javascript
//= require limitcheckbox
```
Or include the minified version
```javascript
//= require limitcheckbox-min
```
## Manual Install
Make sure to include jQuery in your page.
```html
```
And then include **limitcheckbox.js**. There unminified version it's located at the `src` folder. The minified version its located at the `build` folder.
```html
```
## Usage
5 checkboxes and I want to set a limit of 3.
```html
```
```javascript
$('#checkboxes').limitCheckbox(3);
```
### Callback
```javascript
$('#checkboxes').limitCheckbox(3, {
callback: function() {
// Options
}
);
```
Notice that **limitcheckbox.js** will check the checkboxes from your main element when called in order to disable if they're already *checked*.
## Demo
[Click here](http://jsfiddle.net/kinduff/wBZk9/).