var s2 = $("input[name='timSection']:checked").val(); if (typeof(s2) == "undefined") { alert(1) }else{ alert(2) }