Friday, 25 May 2012

How to check radio button selected or not using jquery?

Folks,

Use the following code:

function validateMultipleRadio(formId){
        if(formId == undefined){
            var totalInput = $('input:radio').length;
        }else{
            var totalInput = $('#'+formId+' input:radio').length;
        }
        var checkedValues = '';
        if(totalInput > 0){
            $(":input:radio:checked").each(function(){
                checkedValues = checkedValues + ',' + this.value;
            })
        }
        return checkedValues;

}

var checkValues = validateMultipleRadio('frm');
alert(checkValues);



Cheers!

No comments:

Post a Comment