开发者

Using jQuery to disable multiple selects

I have 7 select menus. I want to have the user make three choices, leaving 4 select menus disabled. Here is the link: http://www.missionsolano.org/support_volunteer_form.php (under Areas of Interest).

I open to using jQuery form validator plu开发者_JAVA百科gins as well. Anyone have any tips?


This seems to work for me.

$('.aoi_select').change(function(){
    var totalSelected = $('.aoi_select[selectedIndex!=0]').length;
    if (totalSelected >= 3)
        $('.aoi_select[selectedIndex=0]').attr('disabled', 'disabled');
    else
        $('.aoi_select').removeAttr('disabled');
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜