Skip to content
Advertisement

Uncaught TypeError: form.submit is not a function in form validate() function

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();
                }

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>

Advertisement

Answer

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>
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement