Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
HTMLのフォームにいくつかの入力があり、そのうちのいくつかは「select」です...すべての入力は必須であるため、alllに値があるかどうかを確認する必要があります...そのために、すべての「select」要素にはデフォルトでvalue=0が選択されている「nd」オプション...そして「保存」ボタンは「無効」です。
JQueryを使用して、すべての「選択」に0とは異なる値の「選択済み」オプションがあるかどうかを確認し、ある場合は「保存」ボタンを「有効」にします。
var allSelect = $('select').filter(function() { return this.value != 0 ; }).length === $('select').length; $(':submit').prop('disabled', !allSelect);
作業サンプル