2012-11-26 2 views
0

jquery multiselect plugin을 사용하고 있습니다. 지금은 사용자가 아래의 코드로 체크 박스를 선택했는지 확인하고 있습니다.다중 선택 jQuery 플러그인에 최소한 하나의 확인란이 선택되었는지 확인하는 방법

function fntemp() 
{ 
var values = $("select").val(); 
alert(values); 
if(!values){ 
alert("Please select atleast one value from the dropdown.");  
} 
} 

"모두 선택"링크를 클릭하면 작동하지 않습니다. 어떤 제안?

+0

[** 질문 **] (https://stackoverflow.com/questions/46024810/multiselect-jquery-check-my-multiple-select-if-at-least-one-option s-should-be/46024908 # 46024908) 귀하의 질문에 대한 완벽한 해결책을 가지고 있습니다 –

답변

2

, 당신은

$("select").multiselect("getChecked"); 

을 사용하여 모든 체크 체크 박스의 배열을 얻을 수있는 당신이 때문에 같은 것을 할 수있는 가정

if ($("select").multiselect("getChecked").length == 0) 
{ 
    alert("Please select atleast one value from the dropdown."); 
} 
3

작동합니다 : 문서를 보면

var test = $("select option:selected").length; 
관련 문제