Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix the disabled state of radio buttons for custom forms

  • Loading branch information...
commit 2a98ddde179b03112669fab68c0459653143ca51 1 parent 07dff79
@mkelly12 mkelly12 authored
Showing with 31 additions and 6 deletions.
  1. +8 −6 javascripts/jquery.customforms.js
  2. +23 −0 test.html
View
14 javascripts/jquery.customforms.js
@@ -144,13 +144,15 @@ jQuery(document).ready(function ($) {
var $input = $element.prev(),
input = $input[0];
- $('input:radio[name="' + $input.attr('name') + '"]').each(function () {
- $(this).next().removeClass('checked');
- });
- input.checked = ((input.checked) ? false : true);
- $element.toggleClass('checked');
+ if (false == $input.is(':disabled')) {
+ $('input:radio[name="' + $input.attr('name') + '"]').each(function () {
+ $(this).next().removeClass('checked');
+ });
+ input.checked = ((input.checked) ? false : true);
+ $element.toggleClass('checked');
- $input.trigger('change');
+ $input.trigger('change');
+ }
}
$('form.custom span.custom.checkbox').live('click', function (event) {
View
23 test.html
@@ -352,6 +352,29 @@
</p>
</div>
</div>
+
+ <h3>Disabled Forms</h3>
+ <form class="custom">
+
+ <label for="radio1"><input name="radio1" type="radio" id="radio1" style="display: none; "> Radio Button 1</label>
+ <label for="radio2"><input name="radio1" type="radio" id="radio2" style="display: none; "> Radio Button 2</label>
+ <label for="radio3"><input name="radio1" disabled="DISABLED" type="radio" id="radio3" style="display: none; "> Radio Button 3</label>
+
+ <label for="checkbox1"><input type="checkbox" id="checkbox1" style="display: none; ">Label for Checkbox</label>
+ <label for="checkbox2"><input type="checkbox" id="checkbox2" checked="" style="display: none; ">Label for Checkbox</label>
+ <label for="checkbox3"><input type="checkbox" disabled="DISABLED" checked="" id="checkbox3" style="display: none; ">Label for Checkbox</label>
+
+ <p>This is a paragraph with an inline select element.
+ <select disabled="DISABLED">
+ <option>Option 1</option>
+ <option>Option 2</option>
+ <option>Option 3</option>
+ <option>Option 4</option>
+ <option>Option 5</option>
+ <option>Option 6</option>
+ </select>
+ </p>
+ </form>
</div>
Please sign in to comment.
Something went wrong with that request. Please try again.