Tuesday, May 17

Using Jquery Check if radio button is selected

I had to validate a form for checking if a radio button is selected or not using jquery.

The html code

<input type="radio" name="user_type" value="1">Individual<br />
<input type="radio" name="user_type" value="2">Firm / Organization<br />

Searching on google i found out this script which best suited my requirements

if(!$("input[@name = 'user_type']:checked").val()){
     error = "Please select user type from given options";
}

Be the first one to Comment!!!

Post a Comment