return $('#attending_day_1 input[type=radio]:checked').val() = " "
I want to check if returned value is empty/radio button is unchecked. This is not working, what am I missing?
return $('#attending_day_1 input[type=radio]:checked').val() = " "
I want to check if returned value is empty/radio button is unchecked. This is not working, what am I missing?
use this:
return $('#attending_day_1 input[type=radio]').is(":checked");
in javascript, = is assignment, == is a comparison operator. " " is a valid non empty string - try this:
'' === ' '
also, val() returns the value of the input element. if you want to check if none of the buttons are checked, see if the length of the jQuery selection is 0.
return ! $('#attending_day_1 input[type=radio]:checked').length
(note 0 is falsy, so !0 is true)
As a function, the line below will return true
if there are no checkboxes selected:
return $('#attending_day_1 input[type=radio]:checked').length === 0;