Friday, February 6, 2015

[jQuery] 判斷 checkbox 被選取了幾個 (checked) (常用於表單檢查 "至少要選取一個 才能送出" )


if($("input[name='id[]']:checked").length == 0) {
  alert("請至少選擇一個ID");
  return false;
}

No comments:

Post a Comment