Is there a way I can tell how many times a from submit button has been clicked using JQuery if so can some one please provide a code sample? Thanks!
+1
A:
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.
Daniel Vassallo
2010-03-23 22:32:12
+1
A:
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++;
});
});
Hugh
2010-03-23 22:35:03
You missed a space in your selector.
SLaks
2010-03-23 22:35:41
It's not required for "elementType:identifier" combinations (i.e. `("form#Submit")` or `("form.submit")`).
Nathan Taylor
2010-03-23 22:55:52
@Nathan: `#Submit` is an element in the form. His code will not match anything.
SLaks
2010-03-24 01:21:53
Good point. I was thinking in terms of a form named submit, but yeah based on the html, that definitely won't work! :)
Nathan Taylor
2010-03-24 01:26:41