最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Uncaught TypeError: form.submit is not a function in form validate() function - Stack Overflow

programmeradmin4浏览0评论

when form submit and if validation triger true than its display error on form.submit();

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

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>

when form submit and if validation triger true than its display error on form.submit();

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

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>
Share Improve this question edited Mar 15, 2023 at 7:22 AndrewL64 16.3k8 gold badges50 silver badges85 bronze badges asked Jan 11, 2019 at 10:16 patel jaypatel jay 1352 silver badges13 bronze badges 3
  • Can you post your HTML <form> in your question too. – AndrewL64 Commented Jan 11, 2019 at 10:23
  • html form are too long – patel jay Commented Jan 11, 2019 at 10:28
  • You might need to manual type check if the requested form is actual a form. Something like this if (typeof(form) == <SOME_TYPE>) {form.submit()} – user11367277 Commented Jan 11, 2019 at 10:31
Add a comment  | 

2 Answers 2

Reset to default 18

You most probably have a button or input in your form with id="submit" and/or name="submit" like this:

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

This will change form.submit() to a field reference rather than a method call. You can verify this by console logging form.submit() which will most probably return the <button type="submit" name="submit" id="submit">Submit</button> element instead.

To fix this, you need to either remove the id="submit" and/or name="submit" attributes or change them to something else like this:

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

simply change input type submit or button type submit name = submit to othername and id name also same as name

  <input type="submit" name="submit"  id= "save" class="btn green"> 
    change to like this and error solved in my case 
    <input type="submit" name="save"  id= "save" class="btn green">
发布评论

评论列表(0)

  1. 暂无评论