IE 10、8 行的表单重置堆栈溢出

Form reset Stack overflow at line IE 10, 8

我正在使用如下表格,但在 IE 中出现错误 Stack overflow at line: 367

<form id="appointmentForm" onreset="resetAppointmentForm()" action="" method="post" novalidate class="appointmentForm">

在上面的表单中,标记 onreset="resetAppointmentForm() 属性导致错误。从标记中删除它可以解决错误,但不会重置表单。

function resetAppointmentForm() {
    document.forms['appointmentForm'].reset();
    $('.appointmentForm .alert').remove();
}

在你的 form 标签中你有这个:

onreset="resetAppointmentForm()"

在那个函数中你有这个:

document.forms['appointmentForm'].reset();

所以...触发表单重置会触发表单重置。那是无限递归。因此,堆栈溢出错误。

从函数中删除该行。事件处理程序无需触发自身。