Tuesday, July 30, 2013

How to bind event on form submit using Jquery:

How to bind event on form submit using Jquery:


Code For:
Bind an event handler to the "submit" JavaScript event, or trigger that event on an element.SyntaxTrigger the submit event for the selected elements:$(selector).submit() Attach a function to the submit event:$(selector).submit(function)

=========================================

<form id="frm1" action="some.html">
  <input type="text" value="hello world"
/>
  <input type="submit" value="Submit Data"
/>
</form>
<div
id="div1"
>  Some text</div>

------Call submit------

$('#frm1).submit(function() {
  alert('Handler for .submit() called.');           //any function call

  return false;
});
-----------------------
$(
'#div1).click(function() {
  $('#frm1).submit();
});