ppbb123 Posted September 19, 2012 Report Share Posted September 19, 2012 How to Disable the Return Key for submitting a record? Thanks. Quote Link to comment Share on other sites More sharing options...
0 HongTaiLang Posted September 19, 2012 Report Share Posted September 19, 2012 Try to add the code to the head of your DataPage: <script language="javascript" type="text/javascript"> function stopRKey(evt) { var evt = (evt) ? evt : ((event) ? event : null); var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null); if ((evt.keyCode == 13) && (node.type=="text")) { return false; } } document.onkeypress = stopRKey; </script> Quote Link to comment Share on other sites More sharing options...
0 kRv Posted September 27, 2012 Report Share Posted September 27, 2012 Small addition. If document already has some handler we need keep it and execute. Please look at code bellow. var prevKeyPress = document.onkeypress; document.onkeypress = function(e) { if(!e) { e = window.event; } try { if (prevKeyPress) prevKeyPress(e); } catch (ex) { } // Do something } Quote Link to comment Share on other sites More sharing options...
0 altonherry Posted October 1, 2012 Report Share Posted October 1, 2012 Nice post. I like it. Thanks for sharing these information. Keep it up. Quote Link to comment Share on other sites More sharing options...
0 HongTaiLang Posted October 10, 2012 Report Share Posted October 10, 2012 BTW, it is only for text. To disable key press in password, checkbox and radio button fields: if ((evt.keyCode == 13) && ((node.type=="text") || (node.type=="password")|| (node.type=="checkbox")|| (node.type=="radio"))) Quote Link to comment Share on other sites More sharing options...
0 IamNatoyThatLovesYou Posted March 21, 2023 Report Share Posted March 21, 2023 Hello Everyone, you can also try this code below to not submit data when the enter key is pressed. <script> document.addEventListener('BeforeFormSubmit', function(event) { event.preventDefault(); }); </script> Quote Link to comment Share on other sites More sharing options...
Question
ppbb123
How to Disable the Return Key for submitting a record? Thanks.
Link to comment
Share on other sites
5 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.