How To Get the Value of a Checked Radio Button in a Specific Form
How To Get the Value of a Selected Radio Button in a Specific Form: jQuery(‘input[name=radioName]:checked’, ‘#yourForm’).val()
How To Get the Value of a Selected Radio Button in a Specific Form: jQuery(‘input[name=radioName]:checked’, ‘#yourForm’).val()
1 2 3 4 5 6 7 8 9 |
if ( ! jQuery('input[name=yourRadioGroup]').is(':checked') ) return false; ~OR~ if (! jQuery('input[name=yourRadioGroup]:checked').val()) { alert('Please make a selection...'); } else { alert('Thank you for making a selection!'); } |
Just be sure to add the class “yourClass” to each checkbox in the group you wish to count and it is as simple as:
1 |
alert( 'Qty checked: ' + jQuery('.yourClass:checked').length ); |
Important Note: This solution REQUIRES jQuery 1.6 or better due to the addition of the :focus selector! Here is how I used it for a form in a jQuery UI dialog:
1 2 |
var Info = jQuery(this).find(':focus').get(0).tagName; if (tagName == 'INPUT') return false; |
1 |
jQuery('#yourselect option').attr("selected","selected"); |
1 2 3 4 5 |
var SelectedValue = jQuery('#PickList').val(); var SelectedText = jQuery('#PickList :selected').text(); if (SelectedValue) { alert('You chose: '+SelectedText); } |