Friday, February 18, 2011

Useful jQuery Tips

Validate radio button is selected:
if ($("#dom_id:checked").val()) {
alert("Radio button is selected!);
} else {
alert("Nothing selected!);
}

Validate checkbox is selected:
if ($("#dom_id").is(':checked')) {
alert("Checkbox is selected!);
} else {
alert("Nothing selected!);
}