{"id":1198,"date":"2013-08-06T00:11:17","date_gmt":"2013-08-06T00:11:17","guid":{"rendered":"http:\/\/www.phpmind.com\/blog\/?p=1198"},"modified":"2013-08-06T01:16:53","modified_gmt":"2013-08-06T01:16:53","slug":"how-to-prevent-form-submission-by-pressing-entering-key","status":"publish","type":"post","link":"https:\/\/www.phpmind.com\/blog\/2013\/08\/how-to-prevent-form-submission-by-pressing-entering-key\/","title":{"rendered":"How to prevent form submission by pressing entering key?"},"content":{"rendered":"<p>Stop form submission by pressing enter key.<br \/>\nthis code will prevent form posting by pressing enter key or save time accidental form submission.<\/p>\n<pre lang=\"php\">\r\n\r\n<form id=\"my_form_id_here\">\r\nAll form element and your code here.\r\n<\/form>\r\n\r\n\r\n<script>\r\n    $(document).ready(function(){\r\n        jQuery.each($(\"#my_form_id_here\").find('input'), function(){\r\n            $(this).bind('keypress keydown keyup', function(e){\r\n                if(e.keyCode == 13) { e.preventDefault(); }\r\n            });\r\n        });\r\n    });\r\n<\/script>\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Stop form submission by pressing enter key. this code will prevent form posting by pressing enter key or save time accidental form submission. All form element and your code here.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[30],"tags":[],"class_list":["post-1198","post","type-post","status-publish","format-standard","hentry","category-jquery"],"_links":{"self":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts\/1198","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/comments?post=1198"}],"version-history":[{"count":2,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts\/1198\/revisions"}],"predecessor-version":[{"id":1203,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts\/1198\/revisions\/1203"}],"wp:attachment":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/media?parent=1198"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/categories?post=1198"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/tags?post=1198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}