Delayed Form Submit

Simple JS example for submitting a form with two seconds delay

by Patrick Hund

HTML

<form id="delayedForm" action="javascript:alert('form submitted with delay')"  onsubmit="document.getElementById('submitButton').setAttribute('disabled', 'disabled'); window.setTimeout(function () { document.getElementById('delayedForm').submit(); }, 2000); return false">
    <p>
        <label for="name">name:</label>
        <input type="text" name="name" id="name">
    </p>
    <p>
        <label for="password">password:</label>
        <input type="password" name="password" id="password">
    </p>
    <p>
        <button id="submitButton" type="submit">
            Submit!
        </button>
    </p>
</form>