0

I am trying to set a delay when a user clicks submit on a form before it submits.. I have an image that displays to test the click event, and it works fine, but the form does never submit...

Here is my HTML form:

<form class='loginForm1' action='verify_credentials.php' method='post'>
    <fieldset>
        <legend>Log into Answer Tree</legend>
        <label>Username</label>
        <input class='inputs' name='username' type="text" placeholder="Enter username...">
        <label>Password</label>
        <input class='inputs' name='password' type="text" placeholder="Enter password...">
        <label class="checkbox">
            <input type="checkbox">Remember me</label>
        <button id='submit' type='button' class="btn btn-success">Submit</button>
    </fieldset>
</form>

And here is the script:

$(document).ready(function () {
    $(".containerLogin img").hide();
});

$(function () {
    $("#submit").click(function () {
        $(".containerLogin img").show();
        setTimeout(submitForm, 1000);
    });
});

function submitForm() {
    $(".loginForm1").submit();
}

I got this error message:

Uncaught TypeError: Property 'submit' of object #<HTMLFormElement> is not a function

Derek 朕會功夫
  • 84,678
  • 41
  • 166
  • 228
Wil Prim
  • 1,767
  • 6
  • 35
  • 51

1 Answers1

1

You have a problem with the naming of your button, it overrides the submit() handler.

Rename the button to

<button id='btnSubmit' type = 'button' ...

And change your selector to match.

epascarello
  • 185,306
  • 18
  • 175
  • 214