pixeltrace Posted March 22, 2007 Share Posted March 22, 2007 guys, is there a way that we can disable the <ENTER> key for the submit button? because i have a form and all fields should be filled up. but what happens is if the person filling up the form accidentally hit the <ENTER> key the form will be submitted eventhough he/she hasnt completed the form yet. how should i fix this? thanks! Quote Link to comment https://forums.phpfreaks.com/topic/43784-how-to-disable-the-enter-key-for-the-submit-button/ Share on other sites More sharing options...
wilorichie Posted March 22, 2007 Share Posted March 22, 2007 People that HAVE filled in the form and wish to press enter will get annoyed. Simply check that all contents are filled in on the next page, if not, send them back with all the details back into the page. Or just use JavaScript to save time for them Quote Link to comment https://forums.phpfreaks.com/topic/43784-how-to-disable-the-enter-key-for-the-submit-button/#findComment-212575 Share on other sites More sharing options...
jitesh Posted March 22, 2007 Share Posted March 22, 2007 <input type="submit" name="submit" value="Submit" onclick="return checkkey(event.keyCode)"> <script language=javascipt> function checkkey(key){ if(key == 13){//You have pressed enter return false; }else{ return true; } </script> Quote Link to comment https://forums.phpfreaks.com/topic/43784-how-to-disable-the-enter-key-for-the-submit-button/#findComment-212600 Share on other sites More sharing options...
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.