Jump to content

Recommended Posts

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.

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.

 

 

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.