how do i get an input type="submit" onclick event to fire the commitfunds.valdiate? i can't use a class or id. it must be an onclick event.
here's the code:
<?
foreach ($db->row AS $val){
$("#commitfunds<?=$val['id']?>").validate({
submitHandler: function(form){
$.post('/pages/aditorials/add_to_cart.php',
$("#commitfunds<?=$val['id']?>").serialize(), function(data) {
$('#wb_fundsresults<?=$val['id']?>').html(data);
});
}
});
<form>
<input type="text" name="commit_funds">
<input type="submit" onclick="$(#commitfunds).validate()<?=$val['id']?>;return false;">
</form>
<div id="#wb_fundsresults<?=$val['id']?>"></div>
?>
thanks
asked Oct 22, 2011 at 6:02
complexi
4273 gold badges10 silver badges20 bronze badges
1 Answer 1
$("input[type=submit]").click(function(){
// do your stuff
});
EDIT: 11/11/14
You can use .submit()
$("form").submit(function(event){
// do your stuff
});
answered Oct 22, 2011 at 6:15
Dhiraj
33.7k10 gold badges65 silver badges78 bronze badges
Sign up to request clarification or add additional context in comments.
2 Comments
Steve Robbins
or check for the form being submitted
$('form').submit(function() { /* do stuff */ });complexi
thanks for the answers. are these for the jquery function or the onlick event? i need it for the onlick event. user clicks the submit button fires the onclick event which then executes the jquery function.
lang-js