How would I add additional functionality to the jQuery validation submitHandler that is set in another script? I cannot modify the source JavaScript that is defining the submitHandler in the first place. Instead, I need to add some additional functionality to it from a subsequent script that runs. Here is some scaled-down pseudo-code for the .js file that is defining the submitHandler in the first place–which I cannot directly modify:
$("#frmReg").validate({
invalidHandler: function(e, validator) { //code here ... not relevant },
submitHandler: function() {
window.onbeforeunload = null;
$('#myForm')[0].submit();
},
rules: { firstname: { required: true } },
messages: { firstname: { required: 'First name is required' } }
});
Essentially, I want to bind a second function to the existing submitHander.
I glanced over the source and I think this should work: