javascript - 未捕获的 TypeError : form. 提交不是表单 validate() 函数中的函数

标签 javascript html jquery forms validation

当表单提交并且验证触发 true 时,在 form.submit() 上显示错误;

 submitHandler: function(form) {
                    debug: true,
                    success1.show();
                    error1.hide();
                    form.submit();
                }

enter image description here

form html like this 
     <form method="post" id="clientordeR_create12" onsubmit="enableItemtax();"
                              action="<?php echo base_url('Clientorder/save'); ?>">

 all input eliments here

     <input type="submit" name="submit" class="btn green"
                                                   value="Save &amp; Print" formtarget="_blank" id="spSlip"/>
    </form>

最佳答案

您的表单中很可能有一个带有 id="submit" 的按钮或输入 和/或 name="submit" 像这样:

<form>
  <input type="text" name="someName" />
  <input type="email" name="someEmail" />
  <!-- Other form elements -->
  <button type="submit" name="submit" id="submit">Submit</button>
</form>

这将会改变form.submit()到字段引用而不是方法调用。您可以通过控制台日志记录 form.submit() 来验证这一点这很可能会返回 <button type="submit" name="submit" id="submit">Submit</button>元素代替。

要解决此问题,您需要删除 id="submit" 和/或 name="submit" 属性或将它们更改为其他类似这样的内容:

<form>
  <input type="text" name="someName" />
  <input type="email" name="someEmail" />
  <!-- Other form elements -->
  <button type="submit" name="submitBtn" id="submitBtn">Submit</button>
</form>

关于javascript - 未捕获的 TypeError : form. 提交不是表单 validate() 函数中的函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54144436/

相关文章:

javascript - 了解 alert() 如何影响浏览器事件循环

javascript - 未捕获的类型错误 : xyz is not a function (when calling it from inside string)

javascript - 根据 SQL 值更改 css

html - 如何在页面中间垂直和水平居中 slider - CSS,HTML

jquery - 当我的窗口滚动> 50时如何添加:hover on my class .事件

javascript - 一页中有多个模式,其中一些模式是轮播

javascript - 使用 Jasmine 测试 modal.open()

javascript - 如何为 [ngStyle] 设置动态 css 样式

html - 使 <td> 跨越表格中的整行

jquery - 在 django 中使用序列化的 ajax post 数据