Thursday, 3 December 2015

How to validate my radio button fields using magento?

If you are using magento form validation add class(magento-checkbox-validation) in your radio inputs(of same group):
class="magento-checkbox-validation" OR use "validate-one-required" on
 the last radio/checkbox in the group


And if you are writing your custom script then add this function in script :

 function validateRadioIsSelected()
{
 var options = $$('input.Classname');
    for( i in options ) {
        if( options[i].checked == true ) {
            return true;
        }
    }
    return false;
}

if above function return true, it means your radio is selected

No comments:

Post a Comment