Reputation: 15
Is there a way I can tell how many times a form submit button has been clicked using jQuery? If so, can someone please provide a code sample? Thanks!
Upvotes: 1
Views: 10917
Reputation: 1212
Easy.
html:
<form id="form">
<input type="button" id="Submit" name="Submit" value="Submit" />
</form>
javascript:
var count = 0;
$(document).ready(function(){
$("form#Submit").submit(function(){
count++;
});
});
Upvotes: 4
Reputation: 344471
If you are posting the form to the server, you may find it easier, and more reliable, to track the form submissions from the server-side.
Upvotes: 1