I am trying to add the following:
onsubmit="return processForm(this);
to this form id
<form id="formbuilder" name="featured_homes" method="post" action="fb/feedback.php">
with jquery so that the final result reads as:
<form id="formbuilder" name="featured_homes" method="post" action="fb/feedback.php" onsubmit="return processForm(this);">
Here is my attempt:
$('#formbuilder').onsubmit('return processForm(this);');
this is not working, any ideas to adjust?
You actually want to add the attribute? I wouldn't do it, but here is how:
$('#formbuilder').attr('onsubmit','return processForm(this);');
WORKING JSFIDDLE DEMO
OUTPUT:
<form id="formbuilder" name="featured_homes" method="post" action="fb/feedback.php" onsubmit="return processForm(this);">
Here's the equivalent without resorting to inline JS:
$('#formbuilder').on('submit', function() {
return processForm(this);
});
Which can also be written as:
$('#formbuilder').submit(function() {
return processForm(this);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With