我有以下表格:
但现在,一旦我点击“转到下一部分”按钮,我就没有得到任何回复而且我无法转到下一页,因为我收到了以下错误。
但此错误仅在Firefox中出现。我改用Chrome后,就可以了。
这是示例HTML:
<div class="section">
....
</div>
<div class="section">
....
</div>
<button type="button" class="btn btn-warning">Go to Next Section</button>
这是剧本:
$('.btn-warning').click(function () {
var container = $(this).closest('.section');
var isValid = true;
$.each(container.find('.form-control'), function () {
$('form').validate().element($(this));
if (!$(this).valid()) {
isValid = false;
return false;
}
});
if (isValid) {
container.next('.section').show().find('input').first().focus();
container.hide();
} else {
container.find('.error').text('please complete');
}
});