Javascript examples for DOM HTML Element:Input Text
Stop the page refreshing when enter is pressed in a form input element
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <form id="someForm" action="" method="post" onsubmit="postText();return false"> <input type="text" id="demoText"> <button type="submit" id="postBtn">Post</button> </form> <script type="text/javascript"> function postText() {/*from w w w . ja v a 2 s.c om*/ console.log("Random Function..."); } </script> </body> </html>