html - Function not getting loaded onsubmit in javascript -


i have simple form (removed irrelevant parts) onsubmit don't seems working.

function displayorder() {       document.writeln( "<h1>order details</h1>" );  }
<form id = "myform" action="" onsubmit="return displayorder();"  >       <input type = "submit" id = "submit"  />  </form>

you don't return false @ end of function :

function displayorder() {       document.writeln( "<h1>order details</h1>" );       return false;  }
<form id = "myform" action="" onsubmit="return displayorder();"  >       <input type = "submit" id = "submit"  />  </form>

add return false @ end of function prevent reloading page , don't send form. return true sends form. default form sent directly if not add return false

edit :

maybe function not loaded in dom. try declare function :

displayorder = function () {      document.writeln( "<h1>order details</h1>" );      return false; } 

with way displayorder defined @ run-time


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -