Skip to main content

Bug Tracker

Side navigation

#4390 closed bug (invalid)

Opened March 19, 2009 10:30PM UTC

Closed March 21, 2009 01:42AM UTC

$('input[type=checkbox]').val() doesn't return checked or unchecked status

Reported by: andras Owned by:
Priority: major Milestone: 1.4
Component: core Version: 1.3.2
Keywords: Cc:
Blocked by: Blocking:

$('input[type=checkbox]').val() returns always the attribute value of the input and not the checked or unchecked status wich really tells the user value.

Attachments (0)
Change History (2)

Changed March 20, 2009 05:16AM UTC by JDay comment:1

Checkbox inputs store their checked state in the presence of a 'checked' attribute, not in 'value'. Any value, for 'checked' will result in a checked input, i.e. <input type="checkbox" checked="false" value="false" /> would be checked. The absence of the 'checked' attribute will prevent the value from being sent at all on a form submit. The correct method for determining check state is: $('input[type="checkbox"]').is('[checked]')

Changed March 21, 2009 01:42AM UTC by dmethvin comment:2

resolution: → invalid
status: newclosed

You haven't said what value you would expect from

when the checkbox isn't checked but whatever it returned would be a surprise for existing code. Since
is a symmetrical getter/setter for other elements, I don't think a special case for checkboxes is warranted.