1

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

1 Answer 1

6
$("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
Sign up to request clarification or add additional context in comments.

2 Comments

or check for the form being submitted $('form').submit(function() { /* do stuff */ });
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.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.