Reputation: 3929
Hi i want to know how to tell if a event was fire within 2.5 seconds.
here is external function written by some other developer.
function validateAndSubmit() {
if (validateRule(document.getElementById("inputElem").value) {
document.form.submit;
} else {
alert ("Value is wrong");
}
}
<input type="button" onclick="validateAndSubmit();" id="updatePage"/>
I have a jquery listener.
$("#updatePage").click(function() {
popupWaitingDialog();
setTimeout(function() {
// insert code to see if submit was fire causing page to load or unload.
hideWaitingDialog();
}, 2500);
});
I have a waiting dialog that shows up, if the validation fail, I want to be able to hide it. The only way i know if the validation fail is if submit or reload event is fire.
Upvotes: 0
Views: 361
Reputation: 781096
Add the popup to the submission function:
function validateAndSubmit() {
if (validateRule(document.getElementById("inputElem").value) {
popup WaitingDialog();
document.form.submit();
} else {
alert ("Value is wrong");
}
}
You can then remove the click
handler. Alternatively, you could keep the click
handler and add the validation code check there:
$("#updatePage").click(function() {
popupWaitingDialog();
validateAndSubmit(); // Doesn't return unless validation fails
hideWaitingDialog();
});
Upvotes: 1