monkeytooth Posted April 16, 2009 Share Posted April 16, 2009 ALright I am a bit confused. I notice from time to time on forms I am working on that if I have a single line text area and hit the "Return (or Enter)" key it will attempt to submit the form, however with that it doesnt submit the form data so essentially its like clicking a link. What I would like to know is what is it as what is the cause of this? And is there a work around so that if the key is keyed it either does nothing or actually submits the data. I know when I click the actual submit button on the form it does submit and work accordingly so that all works, but the enter key thing has me stumped. Quote Link to comment https://forums.phpfreaks.com/topic/154371-solved-forms-and-hitting-returnenter-key/ Share on other sites More sharing options...
MatthewJ Posted April 16, 2009 Share Posted April 16, 2009 Do you have your form checking for the submit button when the form is processed? What I mean is, I often see people use something like if(isset($_POST['submit'])) { // Handle the form } Where the button is named "submit" Hitting enter will submit the form (as long as you're not in a multiline textarea) but the form does not get processed because the submit button does not get set unless it is pressed. Quote Link to comment https://forums.phpfreaks.com/topic/154371-solved-forms-and-hitting-returnenter-key/#findComment-811627 Share on other sites More sharing options...
Zane Posted April 16, 2009 Share Posted April 16, 2009 if you have a submit button, the enter key will be activated to submit it instead of a submit button you could use just a regular button and it would solve your ENTER button issue Quote Link to comment https://forums.phpfreaks.com/topic/154371-solved-forms-and-hitting-returnenter-key/#findComment-811628 Share on other sites More sharing options...
monkeytooth Posted April 16, 2009 Author Share Posted April 16, 2009 Checking posted vars is one thing, which I do attempt to do with all forms to help prevent intrusive data posts.. What I was attempting to do, and finally got was supressing the Enter/Return Key from actually attempting to submit the form. Issue was when someone hit Enter/Return aka Key 13, it would do a false submit, the form would act as if it was submitting but the data in the input fields wouldnt go with it. So I wanted to prevent that. Be it by having the enter key act as a submit button of sorts when and if hit it will actually submit the form as if I hit the submit button.. or have it just ignore the key all together. Which its a single line input so the key really isnt needed anyway. Quote Link to comment https://forums.phpfreaks.com/topic/154371-solved-forms-and-hitting-returnenter-key/#findComment-811642 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.