You can most easily cancel a form submit from within the submit handler, so with something like this:
<form onsubmit="return validateClickCount()" />
Now if you have a function validateClickCount
, the submit action will be canceled when it returns false
.
function validateClickCount() {
return false;
}
With this in place, you just need to change your btnCheck_Click
/interval-callback to decrease a global counter and then check that counter in the validateClickCount
.
var count = 61;
function btnCheck_Click() {
myCounter = setInterval(function () {
if (count > 0)
count--;
elem.html( count );
}, 1000);
}
function validateClickCount() {
return count > 0;
}
If you're looking for more information, I suggest looking at this question and the answers too: How do I cancel form submission in submit button onclick event?