以下のコードは、一連の選択ボックスを検証するためのものですが、検証に合格した後、投稿してその投稿ページに移動しません。修正方法を教えてください。return true; を追加しました。最後ですが、うまくいかないようです、ありがとう。
var $selects = $('form select[name^=select]'),
values = [];
$(':submit').click(function(e) {
e.preventDefault();
values = [];
$($selects).each(function() {
if($(this).val()) {
values.push($(this).val());
}
});
if(!values.length) {
alert('Please select all categories');
return false;
}
if(values.length < $selects.length || $.unique(values).length < $selects.length) {
alert('Please select all categories and be unique');
return false;
}
return true;
});