I have the following spring form that execute back end controller and JavaScript function, everything work but I need to execute JavaScript function before submitting the form. How to do that?
The following code submit the form before execute JavaScript.
<form:form modelAttribute="api" id="form">
                <form:textarea path="text" class="form-control" rows="10" id="redacttext"/>
                <button type="submit" class="btn btn-default">Submit</button>
 </form:form>
Javascript function
function dosomething() {
 //do something 
}
Execute javascript function by jquery
$('#form').submit(function() {
      dosomething();
  });
 
     
     
     
    