corrade-http-templates – Blame information for rev 61
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
61 | office | 1 | <!DOCTYPE html> |
2 | <html> |
||
3 | <head> |
||
4 | <script src="http://code.jquery.com/jquery.min.js"></script> |
||
5 | <link href="http://getbootstrap.com/dist/css/bootstrap.css" rel="stylesheet" type="text/css" /> |
||
6 | <script src="http://getbootstrap.com/dist/js/bootstrap.js"></script> |
||
7 | <script src="../js/validator.js" type="text/javascript"></script> |
||
8 | <title></title> |
||
9 | </head> |
||
10 | |||
11 | <body> |
||
12 | |||
13 | <div class="well"> |
||
14 | <form id="myForm"> |
||
15 | |||
16 | <div class="form-group"> |
||
17 | <div class="checkbox"> |
||
18 | <label> |
||
19 | <input type="checkbox" name="check-1" data-chkgrp="check"> |
||
20 | Check 1 |
||
21 | </label> |
||
22 | </div> |
||
23 | |||
24 | <div class="checkbox"> |
||
25 | <label> |
||
26 | <input type="checkbox" name="check-2" data-chkgrp="check"> |
||
27 | Check 2 |
||
28 | </label> |
||
29 | </div> |
||
30 | |||
31 | <div class="checkbox"> |
||
32 | <label> |
||
33 | <input type="checkbox" name="check-3" data-chkgrp="check"> |
||
34 | Check 3 |
||
35 | </label> |
||
36 | </div> |
||
37 | |||
38 | <div class="help-block with-errors"></div> |
||
39 | </div> |
||
40 | |||
41 | </form> |
||
42 | |||
43 | <div class="form-group"> |
||
44 | <button type="submit" form="myForm" class="btn btn-primary">Submit</button> |
||
45 | <button type="reset" form="myForm" class="btn btn-default">Reset</button> |
||
46 | </div> |
||
47 | </div> |
||
48 | |||
49 | <script type="text/javascript"> |
||
50 | $('#myForm').validator({ |
||
51 | custom: { |
||
52 | chkgrp: function ($el) { |
||
53 | var name = $el.data('chkgrp'); |
||
54 | var $checkboxes = $el.closest('form').find('input[data-chkgrp="' + name + '"]'); |
||
55 | |||
56 | if (!$checkboxes.is(':checked')) { |
||
57 | return 'Need at least one checked' |
||
58 | } |
||
59 | } |
||
60 | } |
||
61 | }).on('change.bs.validator', '[data-chkgrp]', function (e) { |
||
62 | var $el = $(e.target) |
||
63 | var name = $el.data('chkgrp') |
||
64 | var $checkboxes = $el.closest('form').find('input[data-chkgrp="' + name + '"]') |
||
65 | |||
66 | $checkboxes.not(':checked').trigger('input') |
||
67 | }) |
||
68 | </script> |
||
69 | |||
70 | </body> |
||
71 | |||
72 | </html> |