Eagletrophy Eagletrophy - 6 months ago 10
jQuery Question

Submitting form with links and jQuery

Submitting a form using a link powered by jQuery is what I am curious about. Do I just bind a click event to the link in the live() event for eg and use a submit() added to the click?

Answer

Ok, I believe this answer's your question. Also, included one with support for validation, cause most form data needs to be validated. Hope this answers your question.

// Not Validation
$("#btnSubmit").click(function() {
    $("#frmToSubmit").submit(); 
});

// With Validation
$("#btnSubmit").click(function() {
    // Will only submit it validate() returns true
    if( validate() ) $("#frmToSubmit").submit();
});
Comments