Javascript examples for DOM HTML Element:Input Submit
Add action handler for form onsubmit
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){// w w w . j a va 2 s. c om document.getElementById('myform').onsubmit = function(e) { procesText(); e && e.preventDefault && e.preventDefault(); return false; } function procesText(){ console.log('do some stuff'); } } </script> </head> <body> <form id="myform"> First Name: <input type="text" id="myText" maxlength="30"> </form> </body> </html>