Alaa Abdelhaq Blog
13 Jul
let say you have a group of radio buttons sharing the same name attribute for sure, and upon submit or some event you want to check if one of these radio buttons was checked or not.
you can do this simply by the following code.
$(document).ready(function(){ $('#submit_button').click(function() { if (!$("input[@name='name']:checked").val()) { alert('Nothing is checked!'); return false; } else { alert('One of the radio buttons is checked!'); } }); }); |
hope this will help you
24 Responses for "Check if a radion button is checked using jquery"
hi keefak? it is helpful indeed!! do you know any useful resourses to learn jQuery other than online tutorials???
Thanks!!! Exactly what I needed.
It’s helpful !
Thanks !
woww this great information for me..thanksss
Thanks ! what i need i got
Hi, just what I needed today! Thank you!
SWEET!
Helped me a bunch for testing if radio button was checked using jquery!! I was even needing to check based on all having the same name. PERFECT!!!
Excellent, this is exactly what i was looking for
thank you so much
@ is deprecated
Thank you, this is a clean and useful example!
I love you
It helps! Thanks.
Thanks! This is what I needed to the site I working on.
awesome; thanks for posting this!
Thanks!!
a
a
It helps me! Thanks for nice post.
thanks…. helped out a lot….
was doing :checked error thanks anyways
It helps me! Thanks for nice post.
thanks for your help……..
Thanks…..
This web page prevented me from returning to the previous page.
This is the kind of coding that makes the Internet a lot less useful and makes me sad.
Leave a reply